Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to interactively see matplotlib plots with QtAgg backend #858

Closed
cactus1549 opened this issue Mar 1, 2022 · 2 comments
Closed

Unable to interactively see matplotlib plots with QtAgg backend #858

cactus1549 opened this issue Mar 1, 2022 · 2 comments
Assignees
Labels

Comments

@cactus1549
Copy link

cactus1549 commented Mar 1, 2022

Environment data

  • debugpy version: 1.5.1
  • OS and version: Windows 10 Pro 21H2 (64-bit) 10.0.19044
  • Python version (& distribution if applicable, e.g. Anaconda): 3.9.4
  • matplotlib
Name                    Version            Build                       Channel
matplotlib                3.4.2            pypi_0                      pypi
matplotlib-base           3.5.1            py39h581301d_0              conda-forge
matplotlib-inline         0.1.3            pyhd8ed1ab_0                conda-forge

The matplotlib settings are:

backend QtAgg        
interactive True     
non interactive False
  • Using VS Code or Visual Studio: 1.64.2

Actual behavior

I would like to be able to debug python scripts that use matplotlib interactively. By interactively I mean placing a break point and watching my figure update as I actually step through my code.

Expected behavior

The figure does not update when stepping through code.

Steps to reproduce:

  1. Create a python script test.py with the following code:
import matplotlib.pyplot as plt
 

figure = plt.figure()
ax = plt.gca()
ax.plot([1,2,3])
ax.set_title("hello")
plt.show()
  1. Place a breakpoint on line 4 and then step through the following lines of code one by one.
  2. The figure appears blank and doesn't update.
@judej judej added the P2 label Mar 1, 2022
@fabioz
Copy link
Collaborator

fabioz commented Mar 3, 2022

As a note, your environment seems pretty strange if you have:

  • matplotlib 3.4.2 pypi_0 pypi
  • matplotlib-base 3.5.1 py39h581301d_0 conda-forge

It's as if you're mixing things and have one part of the matplotlib package from pypi in a version and another part from conda-forge in another version...

Anyways, I was able to reproduce this with an environment with matplotlib 3.5.1 from conda-forge.

The problem is that the backend being chosen now is QtAgg (I think this is something new as it usually just reported Qt5Agg or Qt4Agg).

I'll provide a fix shortly...

@cactus1549 as a workaround, if you can execute:

import matplotlib
matplotlib.use("Qt5Agg")

At the start of your script, things also work.

@fabioz fabioz changed the title Unable to debug python matplotlib plots (related to #603) Unable to interactively see matplotlib plots with QtAgg backend Mar 3, 2022
@fabioz fabioz closed this as completed in 450fe8b Mar 3, 2022
@cactus1549
Copy link
Author

@fabioz, brilliant this works, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants