Python Forum
matplotlib.pyplot functions create new figures instead of applying to the current one - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Data Science (https://python-forum.io/forum-44.html)
+--- Thread: matplotlib.pyplot functions create new figures instead of applying to the current one (/thread-28195.html)



matplotlib.pyplot functions create new figures instead of applying to the current one - karkas - Jul-09-2020

I'm starting to learn matplotlib, following the pyplot tutorial, but something weird—I think—is happening in the very first part.

When I do this,

import matplotlib.pyplot as plt
plt.plot([1, 2, 3, 4])
plt.ylabel('some numbers')
plt.show()
plt.plot([1, 2, 3, 4]) creates the figure, but plt.ylabel('some numbers') creates another figure with the label but with no plot. Nothing about this is mentioned in the tutorial, and I have been reading about the plt functions to see if this is supposed to happen and/or how to fix it, but can't find anything. What can I do about this?

I just installed matplotlib 3.1.3 and I'm running Python 3.7.6 on Spyder 4.0.1

I see that, in this version of Spyder, I don't need to use plt.show(), because all figures are shown in the 'Plots' pane.

Thanks in advance.


RE: matplotlib.pyplot functions create new figures instead of applying to the current one - Monira - Jul-09-2020

i have also problem drawing a plot from a csv file on jupyter notebook....how can i do it?


RE: matplotlib.pyplot functions create new figures instead of applying to the current one - karkas - Jul-09-2020

(Jul-09-2020, 08:13 AM)Monira Wrote: i have also problem drawing a plot from a csv file on jupyter notebook....how can i do it?

Please create a new thread with your issue.