Matplotlib Problems

Greetings:
I have installed Matplotlib for graphing weather reading from a Sense-Hat atop a Raspberry Pi 4 using Buster OS My program calls up Matprolib via pyton3.7 and a Figure 1 box appears but no GRAPH is displayed. When the Figure 1 box does appears, whatever is behind the box on the screen is displayed in the box…

Hey @geotek, thanks for posting! In order to help you with your problem, it would be useful to know a few things:

  1. How did you install matplotlib? (pip? conda? your package manager?)
  2. What backend are you using? (import matplotlib; matplotlib.get_backend())

Is it just one particular plot that doesn’t work or can you not make any plots display at all (i.e. what does plt.subplots(); plt.show() do)?

Greetings Bruno

I used sudo apt-get install python3-matplotlib
I think I may have tried sudo pip3 install matplotlib - first
The python program calls up the Figure 1 box but no graph in the the box, the box shows what ever is behind the Figure 1 box, such as the screen saver.

As far as the “backend” – I am not sure what you mean.
How and where does the “backend” enter the picture?
How do I know what is being used or if used.
I have never used Matplotlib beforee.
Any hep would be greatly appreciated
Thanks Tom

That sounds like you are not running the event loop for the GUI framework. I suspect you will need to call plt.show() (which will block, but you will get a live figure). If you need to interlace the plot with some other work, see https://github.com/matplotlib/matplotlib/pull/4779 (which I really need to finish and get merged) for details.

Can you please provide a minimal amount of code that will reproduce the problem?

Greetings

You mentioned calling (plt.show), I assume you mean that would be included in my python program which i show in the attachment.

Where in the program should (plt.show) be inserted? My python program is supposed to show sense_hat data in a realtime graph.

I am new to matplotlib, so I am not familiar with its use/operation

Thanks

Tom

···

On Tue, Apr 28, 2020 at 12:00 AM tacaswell via Matplotlib nobody@discourse.matplotlib.org wrote:


tacaswell

    April 28

That sounds like you are not running the event loop for the GUI framework. I suspect you will need to call plt.show() (which will block, but you will get a live figure). If you need to interlace the plot with some other work, see https://github.com/matplotlib/matplotlib/pull/4779 (which I really need to finish and get merged) for details.

Can you please provide a minimal amount of code that will reproduce the problem?


Visit Topic or reply to this email to respond.

To unsubscribe from these emails, click here.

In the future, please paste your code as text (not as screen shots).

Where you are calling sleep(1), you want to be calling plt.pause(1) instead.

I have a long standing PR (https://github.com/matplotlib/matplotlib/pull/4779) to add details about how this works (which I just over-hauled and hopefully will go in soon :crossed_fingers:).

1 Like

Greetings

Thank you very much, your recommendation of changing sleep (1) to plt.pause(1) work just fine and solved the problem nicely.

Noted as per your suggestion to include program listing instead of screen shot. Intention was to show that figure 1 was filled with background screen image.

Again thanks for you help in solving my problem.
Tom

Fair enough, but the thing that was most useful in debugging your problem was reading the code on the right side of the screen :stuck_out_tongue_winking_eye: