Pandas graph not showing in ipython laptop as inline

I am trying to plot in the ipython built-in box, but .plot() methos just shows the object information, since

 <matplotlib.axes._subplots.AxesSubplot at 0x10d8740d0> 

but no schedule. I could also show it a graph with plt.show() , but I want to make it inline. so I tried %matplotlib inline and ipython notebook --matplotlib=inline , but that didn't help.

If I use %matplotlib inline , then .plot() shows

 /Users/<username>/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/IPython/core/formatters.py:239: FormatterWarning: Exception in image/png formatter: 'ascii' codec can't decode byte 0xe2 in position 0: ordinal not in range(128) FormatterWarning, 

and using ipython notebook --matplotlib=inline shows the same thing.

+6
source share
3 answers

Edit

 ipython notebook --matplotlib=inline 

to

 ipython notebook --matplotlib inline 

Pay attention to the = sign.

+4
source

I will give you an example based on my comment above:

You have something like this:

 import matplotlib.pyplot as plt %matplotlib inline legend = "\xe2" plt.plot(range(5), range(5)) plt.legend([legend]) 

that leads to:

 UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 0: ordinal not in range(128) 

As I said, this is because matplotlib wants to use unicode strings. Thus, in the process of plotting, matplotlib tries to decode your string in order to convert it to Unicode using decode . However, decode has ascii as the default encoding, and since your character is not ascii , an error is displayed. The solution is to decode the string yourself with the appropriate encoding:

 import matplotlib.pyplot as plt %matplotlib inline legend = "\xe2".decode(encoding='latin-1') plt.plot(range(5), range(5)) plt.legend([legend]) 

enter image description here

By the way, regarding using ipython notebook --matplotlib inline , this is considered bad practice because you are hiding what you did to get the resulting laptop. It is much better to include %matplotlib inline in your notebook.

+3
source

Thanks for the help. I tried all the above but did not work.

here I found that there was a bug in fontmanager.py in matplotlib 1.4.x, fixed with this version of matplotlib development, and it worked.

I am so sorry that I could not find him before. thank you everybody.

0
source

Source: https://habr.com/ru/post/982136/


All Articles