question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

how to stop creating new frame in plot pane for each matplotlib.pyplot command?

See original GitHub issue

This is not a bug report or a feature request, I don’t think. It’s more of a usage help question. If creating an issue here isn’t the right way to get help, my apologies in advance-- direct me to where I should ask.

I would like to be able to add graphic items to an existing figure in a frame of the plots pane, without a new frame appearing there each time I execute a matplotlib.pyplot command.

I undock the plot pane (which btw, other than the confusion I am describing here, I find very helpful!) and run this code:

import matplotlib.pyplot as plt
plt.figure()

At this point there is no frame in the plot pane yet. (Not sure why-- for this first plt.figure() command I guess I would need to do plt.show() to make it appear?)

Anyway, then I do plt.axes() and now there is a frame in the plot pane:

image

Then I do plt.plot(range(10)) with the intent to insert a line in to the existing frame. However, what happens is not as intended-- a second frame appears in the plot pane:

image

Next I want to add a text item to the existing frame so I run plt.text(0.5,0.5,'Text Item') and once again, contrary to my goal, a new (third) frame appears withiin the plot pane (showing only the text item in it):

image

So the bottom line is that apparently I am not properly understanding how to control when plt.show() does or doesn’t execute.

I searched the issues and saw a lot of questions about turning inline plots on and off but this topic seems different. I also looked at the documentation for the plots pane and didn’t find info that would help me out on this.

Thanks in advance to anybody who can bring me up to speed on this!

  • Spyder version: 5.4.0 (conda)
  • Python version: 3.8.13 64-bit
  • Qt version: 5.15.6
  • PyQt5 version: 5.15.7
  • Operating System: Windows 10

DEPENDENCIES

Mandatory:

atomicwrites >=1.2.0 : 1.4.1 (OK) chardet >=2.0.0 : 5.1.0 (OK) cloudpickle >=0.5.0 : 2.2.0 (OK) cookiecutter >=1.6.0 : 2.1.1 (OK) diff_match_patch >=20181111 : 20200713 (OK) intervaltree >=3.0.2 : 3.0.2 (OK) IPython >=7.31.1;<8.0.0 : 7.33.0 (OK) jedi >=0.17.2;<0.19.0 : 0.18.2 (OK) jellyfish >=0.7 : 0.9.0 (OK) jsonschema >=3.2.0 : 4.17.3 (OK) keyring >=17.0.0 : 23.11.0 (OK) nbconvert >=4.0 : 7.2.5 (OK) numpydoc >=0.6.0 : 1.5.0 (OK) paramiko >=2.4.0 : 2.12.0 (OK) parso >=0.7.0;<0.9.0 : 0.8.3 (OK) pexpect >=4.4.0 : 4.8.0 (OK) pickleshare >=0.4 : 0.7.5 (OK) psutil >=5.3 : 5.9.4 (OK) pygments >=2.0 : 2.13.0 (OK) pylint >=2.5.0;❤️.0 : 2.15.7 (OK) pylint_venv >=2.1.1 : 2.3.0 (OK) pyls_spyder >=0.4.0 : 0.4.0 (OK) pylsp >=1.6.0;<1.7.0 : 1.6.0 (OK) pylsp_black >=1.2.0 : 1.2.1 (OK) qdarkstyle >=3.0.2;❤️.1.0 : 3.0.3 (OK) qstylizer >=0.2.2 : 0.2.2 (OK) qtawesome >=1.2.1 : 1.2.1 (OK) qtconsole >=5.4.0;<5.5.0 : 5.4.0 (OK) qtpy >=2.1.0 : 2.3.0 (OK) rtree >=0.9.7 : 1.0.1 (OK) setuptools >=49.6.0 : 65.5.1 (OK) sphinx >=0.6.6 : 5.3.0 (OK) spyder_kernels >=2.4.0;<2.5.0 : 2.4.0 (OK) textdistance >=4.2.0 : 4.5.0 (OK) three_merge >=0.1.1 : 0.1.1 (OK) watchdog >=0.10.3 : 2.1.9 (OK) zmq >=22.1.0 : 24.0.1 (OK)

Optional:

cython >=0.21 : None (NOK) matplotlib >=3.0.0 : 3.6.0 (OK) numpy >=1.7 : 1.23.3 (OK) pandas >=1.1.1 : 1.5.0 (OK) scipy >=0.17.0 : 1.9.1 (OK) sympy >=0.7.3 : None (NOK)

Issue Analytics

  • State:closed
  • Created 9 months ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
DanCodigaMWRAcommented, Dec 12, 2022

ok thanks @dalthviz !

1reaction
DanCodigaMWRAcommented, Dec 12, 2022

Yes. I’m in a more comfortable place now.

Just to confirm though, there is no command I can execute at the commandline in the ipython console that would delete one of the frames within the plots pane, correct? The only way to do this is to click the ‘delete’ (trashcan) button on the plots pane, right?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to remove frame from matplotlib (pyplot.figure vs ...
This should be the accepted answer. "ax.axis("off")" removes everything like: x and y labels, x and y ticks and all (4) borders from ......
Read more >
Interactive figures — Matplotlib 3.6.2 documentation
Matplotlib keeps a reference to all of the open figures created via pyplot.figure or pyplot.subplots so that the figures will not be garbage...
Read more >
Chapter 4. Visualization with Matplotlib - O'Reilly
plot is that it can be used to create scatter plots where the properties of each individual point (size, face color, edge color,...
Read more >
Plots — Spyder 5 documentation
The Mute inline plotting option is enabled by default, preventing your plots from appearing in the Console. If you deactivate this option, figures...
Read more >
Tutorial - Julia Plots
Additionally, we can add more lines by mutating the plot object. This is done by the plot! command, where the ! denotes that...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found