Opened 3 years ago

Last modified 19 months ago

#65145 assigned defect

py39-matplotlib @3.5.2_0: plotting problem in IPython with %matplotlib

Reported by: aaronm6 Owned by: reneeotten (Renee Otten)
Priority: Normal Milestone:
Component: ports Version: 2.7.2
Keywords: Cc:
Port: py-matplotlib

Description

Using py39-matplotlib @3.5.2_0 with IPython (py39-ipython @8.2.0_1) and invoking the matplotlib inline display hook via %matplotlib, is causing a plot-display issue. A figure can be opened, and will accept a plot statement without complaint; however, nothing shows on the plot, until one uses a graphical tool in the plot window (e.g. the zoom tool). The problem does not occur with py39-matplotlib @3.5.1_0 (in this version, the plot will be displayed as usual). Here are some example commands:

$ ipython3-3.9
Python 3.9.12 (main, Mar 25 2022, 04:56:27) 
Type 'copyright', 'credits' or 'license' for more information
IPython 8.2.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: %matplotlib
Using matplotlib backend: MacOSX

In [2]: from matplotlib import pyplot as plt

In [3]: plt.figure()  # (a blank figure window is created)
Out[3]: <Figure size 1280x960 with 0 Axes>

In [4]: plt.plot([1,2,3],[1,2,3],'.')
Out[4]: [<matplotlib.lines.Line2D at 0x13f3540d0>]

Nothing happens; figure window still appears blank. Note that the %matplotlib command invokes the inline display hook, and therefore plotting does not require plt.show(). With earlier matplotlib versions (including 3.5.1_0) the three desired data points, and plot axes, are shown as expected.

No problems observed when not invoking the inline display hook (i.e. %matplotlib)

Using macOS version 11.6.5

Change History (5)

comment:1 Changed 3 years ago by ryandesign (Ryan Carsten Schmidt)

Keywords: matplotlib ipython removed
Owner: set to reneeotten
Status: newassigned
Summary: plotting problem using py39-matplotlib @3.5.2_0 in IPython with %matplotlibpy39-matplotlib @3.5.2_0: plotting problem in IPython with %matplotlib

comment:2 Changed 3 years ago by reneeotten (Renee Otten)

I can indeed reproduce what you're seeing on macOS Catalina as well. However, I am not convinced this is a MacPorts-specific issue as the same happens when I use a virtualenv and install the packages through pip.

Have you verified that it works as intended when installing the packages not through MacPorts (i.e., using conda or with a virtualenv - although in the latter case it might still use MacPort's Python install). Anyway, you probably get my point: is it cause by the way we install things in MacPorts or is it an upstream bug in matplotlib, ipython or any of the other depdencies?

[edit: when you say that it works with `py39-matplotlib @3.5.1_0`, is that with an otherwise identical set of packages; or did you beside `matplotlib` also update the other dependencies? That would help to narrow down where the issue originates from... I just don't have time to do that myself right now, but please feel free to do that and report back here.]

Last edited 3 years ago by reneeotten (Renee Otten) (previous) (diff)

comment:3 Changed 3 years ago by aaronm6

Thanks for checking. Admittedly, I have not tried it with packages installed via e.g. conda; but if you have and you also see this issue, then that does suggest it's not a problem specific to MacPorts. I suspect the ipython devs will care more about this than the matplotlib devs; in any case, I will file a ticket there and update this thread with anything I learn.

Regarding your final question: the packages are otherwise identical. I'm using port activate to toggle back and forth between 3.5.2 and 3.5.1. The problem arose when I did a port upgrade outdated, so a few packages were updated. However, toggling the matplotlib version was the only thing I could find that would impact the observed behavior.

comment:4 in reply to:  3 Changed 3 years ago by reneeotten (Renee Otten)

Replying to aaronm6:

Thanks for checking. Admittedly, I have not tried it with packages installed via e.g. conda; but if you have and you also see this issue, then that does suggest it's not a problem specific to MacPorts. I suspect the ipython devs will care more about this than the matplotlib devs; in any case, I will file a ticket there and update this thread with anything I learn.

To be clear, I didn't try and install the packages through conda to see if the problem exists there as well. If you have the time to try that please do (otherwise I'll get to that at some point). I can poke around in the the matplotlib GitHub a bit to see if there is anything that suggest what has changed between the two versions.

Regarding your final question: the packages are otherwise identical. I'm using port activate to toggle back and forth between 3.5.2 and 3.5.1. The problem arose when I did a port upgrade outdated, so a few packages were updated. However, toggling the matplotlib version was the only thing I could find that would impact the observed behavior.

okay, thank you for clarifying that. We can certainly check to see if upstream (either matploblib or ipython) has any bug reports and/or a possible fix that we can backport in MacPorts.

comment:5 Changed 19 months ago by reneeotten (Renee Otten)

are you still seeing this issue with the latest matplotlib version (i.e., 3.7.1)?

Note: See TracTickets for help on using tickets.