Hi,
in the last days I started to have issues with my notebooks not showing some plots - I get outputs like [<matplotlib.lines.Line2D at 0x16b6dc2e8>] (similarly to #1620 )
In particular, I have a plot disappearing when I add labels such as plt.xlabel - without that it's shown regularly
I always run %matplotlib inline at the beginning of my notebooks
Any idea of what is happening?
Thanks for your support.
ps: on safari 11.0.3 and notebook 5.4.1
ok, it seems that this problem disappears when I comment (do not run)
from IPython.core.interactiveshell import InteractiveShell
InteractiveShell.ast_node_interactivity = "all"
( which I actually really like, as I don't have to print(my_out) at every line ...anyways )
... any idea if there is a conflict there and how to avoid it?
Thanks
Hi. I like to set it "all". Finally, I found that you can put a semicolon after "plt.show()"......... That's great.
ok,
plt.show(); seem to solve the issue (for now) – thanks @junhaowww !
well,
apparently plt.show(); doesn't seem to work always...no idea what's going on...
I see. You can add ; to the last line of codes. For example:
a = 1
b = 1
# do plotting
plt.show();
a = 1
b = 1
# do plotting
plt.show()
# if plt.show() is not on the last line
a = 2; # like this
as soon as I add other plotting commands such as plt.xlabel(my_label) no plot is shown with both
plt.show() or plt.show();
(I also tried to put plt.xlabel(my_label); which does not work either ...)
... there must be some sort of conflict with those commands and the interactiveshell...
ok, it seems to be unrelated to those shell settings. It's probably related to the matplotlib backend settings
I usually use:
%matplotlib inline
sns.set_context('notebook')
%config InlineBackend.figure_format = 'retina'
in a simple example I am working for instance,
plt.hist(my_panads_series) did not work, even with those settings disabled, while my_panads_series.hist() did ... again, no idea ...
ps: I am on mac os 10.13.4, matplotlib 2.2.2, notebook 5.4.1
Unfortunately, I think this is the downside of trying to make plot displaying 'just work' - when it doesn't work, it can be pretty mystifying to figure out what's going wrong. I don't have any great ideas at the moment, sorry. :-(
@takluyver thanks anyway :) – I will update it in case I figure out something more
I cannot plot with axes as well. axes.plot() return a list with a Lines object... No idea what is going on...
ImportError Traceback (most recent call last)
----> 1 get_ipython().magic('matplotlib inline')
/home/shree/anaconda3/envs/tensorflow/lib/python3.4/site-packages/IPython/core/interactiveshell.py in magic(self, arg_s)
2156 magic_name, _, magic_arg_s = arg_s.partition(' ')
2157 magic_name = magic_name.lstrip(prefilter.ESC_MAGIC)
-> 2158 return self.run_line_magic(magic_name, magic_arg_s)
2159
2160 #-------------------------------------------------------------------------
/home/shree/anaconda3/envs/tensorflow/lib/python3.4/site-packages/IPython/core/interactiveshell.py in run_line_magic(self, magic_name, line)
2077 kwargs['local_ns'] = sys._getframe(stack_depth).f_locals
2078 with self.builtin_trap:
-> 2079 result = fn(args,*kwargs)
2080 return result
2081
/home/shree/anaconda3/envs/tensorflow/lib/python3.4/site-packages/IPython/core/magic.py in
186 # but it's overkill for just that one bit of state.
187 def magic_deco(arg):
--> 188 call = lambda f, a, *k: f(a, *k)
189
190 if callable(arg):
/home/shree/anaconda3/envs/tensorflow/lib/python3.4/site-packages/IPython/core/magics/pylab.py in matplotlib(self, line)
98 print("Available matplotlib backends: %s" % backends_list)
99 else:
--> 100 gui, backend = self.shell.enable_matplotlib(args.gui)
101 self._show_matplotlib_backend(args.gui, backend)
102
/home/shree/anaconda3/envs/tensorflow/lib/python3.4/site-packages/IPython/core/interactiveshell.py in enable_matplotlib(self, gui)
2933 """
2934 from IPython.core import pylabtools as pt
-> 2935 gui, backend = pt.find_gui_and_backend(gui, self.pylab_gui_select)
2936
2937 if gui != 'inline':
/home/shree/anaconda3/envs/tensorflow/lib/python3.4/site-packages/IPython/core/pylabtools.py in find_gui_and_backend(gui, gui_select)
257 """
258
--> 259 import matplotlib
260
261 if gui and gui != 'auto':
ImportError: No module named 'matplotlib'
why its showing No module named 'matplotlib' for %matplotlib inline ?
Splitting matplotlib statements into multiple Jupyter input cells may cause nothing to appear. Check if all your statements are in the same cell.
multiple
Yes! Put all in one cell and the pic came out!
hi,@ggrrll, have you solved this problem yet ?
I met this problem recently when using the plt.hist() for the histgram, and the dataset read from mysql. Hoping for your reply. :)
The problem was solved after few weeks since then (no idea how), but I still left it open in case other people had similar issue ... -- we can close I guess
+1
This all worked fine just this morning and then suddenly getting an issue while working on the EDX DAT 228 course for Azure ML.

I still does this problem , charts appear but values does not.
empty charts simply
I'm having a similar problem. When I do fig = plt.figure(), a blank figure pops up, and then I try to add things to it, and nothing happens when I do a plt.show() at the end.
Hey I'm experiencing this issue still. This issue appears not to be resolved. I'm using the latest version of python and when I try to get plots it either doesn't show or gives a textual description of the plot!d
Your plot has been export successfully but without showing in jupyter. %matplotlib inline , insecting this will make it .
Man, this issue is not resolved... I'm facing this nonsense today!!! November 27th, 2019!! I have no idea why the plots won't show! I'm using matplotlib in a colab notebook. :/
I take it back. I just tried @lionlhy suggestion with the "%matplotlib inline" thing and it miraculously worked! Thanks! :P
if you are using %matplotlib notebook
do use-
%matplotlib inline
In jupyter notebook it works, in jupiter lab it does not... why???
An issue with plt.bar() is that if there are too many bars, they are not visible. Try increasing the figure size:
plt.figure(figsize=(20,17))
or reduce x,y to see if they start appearing
or try seaborn.barplot() instead
I take it back. I just tried @lionlhy suggestion with the "%matplotlib inline" thing and it miraculously worked! Thanks! :P
Where you have used "%matplotlib inline"? Writing just above the command line of google colab where i run the file "!python run_file.py" is not worked for me. What may be the solution for google colab?
Try putting all plotting commands in one cell, with the last command in the cell being:
plt.show()
Sometimes this is not necessary --- the plot will show regardless, but it seems to fix the problem for me.
I'm having the same issue... when I make a change of the parameters the plots wont change and when I rerun or reload... i lose all the plots on Jupyter!

I'm having the same issue... when I make a change of the parameters the plots wont change and when I rerun or reload... i lose all the plots on Jupyter!
what version of python are you using?
I'm having the same issue... when I make a change of the parameters the plots wont change and when I rerun or reload... i lose all the plots on Jupyter!
what version of python are you using?
I have Python 2 & 3 installed on my computer. It's showing Python 2 on the top right corner!
this link is useful, It worked for me
https://github.com/matplotlib/ipympl
I take it back. I just tried @lionlhy suggestion with the "%matplotlib inline" thing and it miraculously worked! Thanks! :P
Where you have used "%matplotlib inline"? Writing just above the command line of google colab where i run the file "!python run_file.py" is not worked for me. What may be the solution for google colab?
I'm having the same issue,how did you solve it,looking forward to your reply
I got this issue in my environment. When I combine code in all cells into one. It works! But I believe that this issue is not yet solved.
I have this issue. Using the semicolon after plot "fixes" it, but seems like a bug if that's the workaround. I'm running jupyterlab.
Mr. Lotfey is right. The link helped ( https://github.com/matplotlib/ipympl )
An addon for Jupyther must be installed.
Most helpful comment
Hi. I like to set it "all". Finally, I found that you can put a semicolon after "plt.show()"......... That's great.