Python Forum
matplotlib.pyplot functions create new figures instead of applying to the current one
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
matplotlib.pyplot functions create new figures instead of applying to the current one
#1
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.
Reply


Messages In This Thread
matplotlib.pyplot functions create new figures instead of applying to the current one - by karkas - Jul-09-2020, 08:07 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question I’m trying to create a Power BI Matplotlib quadrant chart and I’m a little stumped. Nidwolff 1 481 Mar-04-2024, 06:07 AM
Last Post: Danishhafeez
  matplotlib.pyplot issue lonaveia 2 2,377 Jul-28-2020, 02:40 PM
Last Post: hussainmujtaba
  Loss and Accuracy Figures. Hani 3 3,074 May-20-2020, 06:55 PM
Last Post: jefsummers
  How do I create these Kernel functions in Python for Gaussian Process Regression? Shivam18 0 2,214 May-20-2020, 03:04 PM
Last Post: Shivam18
  How does pyplot know what was plotted by the output of pandas.DataFrame(...).cumprod( codeowl 2 2,216 Mar-28-2020, 08:27 AM
Last Post: j.crater
  How to create matplotlib subplots from figures vitaly 3 3,145 Mar-02-2020, 12:58 AM
Last Post: scidam
  huge and weird values after applying some calculations karlito 2 2,174 Dec-13-2019, 08:32 AM
Last Post: karlito
  Applying operation to a pandas multi index dataframe subgroup Nuovoq 1 2,667 Sep-04-2019, 10:04 PM
Last Post: Nuovoq
  Superimpose figures Scientifix 2 4,693 Aug-16-2019, 04:06 PM
Last Post: Nitram
  zooming in pyplot window SchroedingersLion 0 2,214 Aug-02-2019, 02:59 PM
Last Post: SchroedingersLion

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020