-
Notifications
You must be signed in to change notification settings - Fork 224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No heatmap shown with seaborn
and %matplotlib widget
#391
Comments
This worked in ipympl 0.8.0 but not in |
@mwaskom do you have any insight? it seems like you just call |
I think I'd want to know a few things
|
Thanks a lot for getting back to me so quickly!
Do you mean like this? %matplotlib widget
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
df = pd.DataFrame([[10, 20, 30, 40], [50, 30, 8, 15],
[25, 14, 41, 8], [7, 14, 21, 28]])
ax = plt.gca()
sns.heatmap(df, ax=ax)
Yes, it seems that works. %matplotlib widget
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
df = pd.DataFrame([[10, 20, 30, 40], [50, 30, 8, 15],
[25, 14, 41, 8], [7, 14, 21, 28]])
plt.pcolormesh(df)
for y in range(df.shape[0]):
for x in range(df.shape[1]):
plt.text(
x + 0.5, y + 0.5, "%.1f" % df.iloc[x, y],
horizontalalignment="center",
verticalalignment="center",
)
%matplotlib widget
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
df = pd.DataFrame([[10, 20, 30, 40], [50, 30, 8, 15],
[25, 14, 41, 8], [7, 14, 21, 28]])
sns.heatmap(df) The same behaviour with sns.heatmap(df, xticklabels=False, yticklabels=False) and sns.heatmap(df, xticklabels=True, yticklabels=True) assuming this is what was meant with
|
Yes that's right about the tick labels. But you could also try isolating the colorbar: it's on by default in the seaborn plot, so you could try turning it off there ( But I think that doesn't answer the other question which is ... can you use other seaborn functions, or is this an issue specific to |
A crucial thing in these tests is probably to always start with |
Also @dominiquesydow can you please post the code snippets as text so that they are copy-pasteable - thanks! |
Hi @ianhi,
I have updated my comment with copy-pasteable code. Also, I have tried to investigate your initial question (my apologies for not getting to at first)
I set up this notebook; below a summary:
|
That behavior all looks correct to me. If you don't provide seaborn with an |
I am having similar issue #60 (comment) |
Hi @mwaskom, Thanks for getting back to me. # First cell
%matplotlib widget
import matplotlib.pyplot as plt
import seaborn as sns
tips = sns.load_dataset("tips")
fig, ax = plt.subplots(nrows=1, ncols=1)
sns.scatterplot(data=tips, x="total_bill", y="tip", hue="time", ax=ax) This works nicely, I get the plot: Then, I call # Second cell
plt.close() Then, I try to plot # Third cell
import numpy as np
uniform_data = np.random.rand(10, 12)
fig, ax = plt.subplots(nrows=1, ncols=1)
sns.heatmap(uniform_data, ax=ax) Do you have an idea on how to make the last plot appear?
With |
I'm confused about how what you're describing there is not represented in the notebook you shared? You seem to be plotting |
My apologies, apparently uploading the notebook to GH makes the heatmap appear... running the same notebook locally shows the behaviour discussed in this comment. For the time being, I will pin |
seaborn
and %matplotlib widget
seaborn
and %matplotlib widget
Oh that's interesting! I'd say this sounds like an issue on the ipympl side of things. I wish I could offer a hypothesis based on the fact that it seems to happen with heatmaps, but nothing comes immediately to mind beyond what I suggested above. |
Thanks for taking the time to discuss this issue with me. Although I cannot offer a solution with the latest |
Yes this is definitely a bug than needs fixing - thanks for finding it! |
Describe the issue
Thank you very much for providing this tool!
I have an apparently
seaborn
-related problem with showing widgets; I am posting this here first. Please let me know if you think this problem is rather onseaborn
's end and I'll repost it there.The problem:
seaborn
figures are not shown in JupyterLab with%matplotlib widget
(they do show up with%matplotlib inline
):No problem with
matplotlib
:Versions
Installed from conda-forge
More versions:
Do you have an idea why this is happening?
The text was updated successfully, but these errors were encountered: