Issue
When I run the below code, I would expect to see the Seaborn figure and then the text from the print statement underneath it, but instead it is on top.
from IPython.core.interactiveshell import InteractiveShell
InteractiveShell.ast_node_interactivity = "all"
tips = sns.load_dataset("tips")
sns.relplot(x = "total_bill", y = "tip", data = tips);
print('this should be at the bottom')
How can I have the print statement display underneath the Seaborn figure?
Solution
The following solution appears to work in my Jupyter Notebook when combined with plt.show()
from matplotlib
. Now the plot will be displayed first before the print
statement gets executed.
As put simply by @ImportanceOfBeingEarnest below, in the absence of plt.show()
in your cell containing the plot command, the plots will be shown at the end of the cell.
%matplotlib inline
from IPython.core.interactiveshell import InteractiveShell
InteractiveShell.ast_node_interactivity = "all"
import seaborn as sns
import matplotlib.pyplot as plt
tips = sns.load_dataset("tips")
sns.relplot(x="total_bill", y="tip", data=tips)
plt.show()
print('this should be at the bottom')
Answered By - Sheldore
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.