BoldingBruggeman / pyncview

PyNcView is a cross-platform NetCDF viewer written in Python. It provides an easy-to-use graphical user interface to the creation of animations and publication-quality figures.
GNU General Public License v2.0
18 stars 1 forks source link

FigureCanvasQTAgg' object has no attribute '_update_dpi' #2

Open knutaros opened 4 years ago

knutaros commented 4 years ago

Traceback (most recent call last): File "/home/kklingbe/.local/lib/python2.7/site-packages/xmlplot-0.9.17-py2.7.egg/xmlplot/mpl_backend_qt4.py", line 43, in paintEvent if self._update_dpi(): AttributeError: 'FigureCanvasQTAgg' object has no attribute '_update_dpi'

jornbr commented 4 years ago

What version of matplotlib?

knutaros commented 4 years ago

Hi Jorn,

2.0.0

Regards, Knut

(never experienced this problem before, but also did not use pyncview for a long time)

On 2/28/20 3:18 PM, jornbr wrote:

What version of matplotlib?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/BoldingBruggeman/pyncview/issues/2?email_source=notifications&email_token=AC2RV6XFAP6XG725JDPWUNDRFEMMVA5CNFSM4K45NJQ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOENIVKVI#issuecomment-592532821, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC2RV6QAGSEVBSHIGOSNWHDRFEMMVANCNFSM4K45NJQQ.

jornbr commented 4 years ago

Hi Knut,

I'm afraid the only solution at the moment is to update to the latest MatPlotLib 2.2. PyNcView/xmlplot inherit from, and adapt, the MPL Qt backend. Therefore they do not work with all (older) MatPlotLib versions…

Best,

Jorn

knutaros commented 4 years ago

Dear Jorn,

thanks for your help. I now installed matplotlib for python3 via pip3. How can I tell/re-install pyncview to use python3?

Cheers, Knut

On 2/28/20 5:39 PM, jornbr wrote:

Hi Knut,

I'm afraid the only solution at the moment is to update to the latest MatPlotLib 2.2. PyNcView/xmlplot inherit from, and adapt, the MPL Qt backend. Therefore they do not work with all (older) MatPlotLib versions…

Best,

Jorn

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/BoldingBruggeman/pyncview/issues/2?email_source=notifications&email_token=AC2RV6VHHJFZVUFLODPE5KTRFE44HA5CNFSM4K45NJQ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOENJEOZY#issuecomment-592594791, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC2RV6TZNNTGWR3UZKPWE2DRFE44HANCNFSM4K45NJQQ.

bolding commented 4 years ago

pip3 install pyncview -- user

tir. 3. mar. 2020 17.14 skrev knutaros notifications@github.com:

Dear Jorn,

thanks for your help. I now installed matplotlib for python3 via pip3. How can I tell/re-install pyncview to use python3?

Cheers, Knut

On 2/28/20 5:39 PM, jornbr wrote:

Hi Knut,

I'm afraid the only solution at the moment is to update to the latest MatPlotLib 2.2. PyNcView/xmlplot inherit from, and adapt, the MPL Qt backend. Therefore they do not work with all (older) MatPlotLib versions…

Best,

Jorn

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub < https://github.com/BoldingBruggeman/pyncview/issues/2?email_source=notifications&email_token=AC2RV6VHHJFZVUFLODPE5KTRFE44HA5CNFSM4K45NJQ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOENJEOZY#issuecomment-592594791 , or unsubscribe < https://github.com/notifications/unsubscribe-auth/AC2RV6TZNNTGWR3UZKPWE2DRFE44HANCNFSM4K45NJQQ .

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/BoldingBruggeman/pyncview/issues/2?email_source=notifications&email_token=ACVA42MUBRSSJ7NN65FVZVLRFUUF3A5CNFSM4K45NJQ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOENUDTZY#issuecomment-594033127, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACVA42OF7QRFCXCQ3KV4OBLRFUUF3ANCNFSM4K45NJQQ .

knutaros commented 4 years ago

On 3/3/20 5:32 PM, Karsten Bolding wrote:

pip3 install pyncview -- user

thanks karsten. installation worked. (and for the manual way I would do python3 setup.py?)

anyhow, after installing pyqt4 for python3 I now get this error:

pyncview flexout.nc Unable to import xmlplot (https://pypi.python.org/pypi/xmlplot) Try "pip install xmlplot". Error: cannot import name 'FigureCanvasQT'

but even after

pip3 install --user xmlplot

the error still exists.

btw: do I need to add your direct mail addresses, or do you already receive from github?

tir. 3. mar. 2020 17.14 skrev knutaros notifications@github.com:

Dear Jorn,

thanks for your help. I now installed matplotlib for python3 via pip3. How can I tell/re-install pyncview to use python3?

Cheers, Knut

On 2/28/20 5:39 PM, jornbr wrote:

Hi Knut,

I'm afraid the only solution at the moment is to update to the latest MatPlotLib 2.2. PyNcView/xmlplot inherit from, and adapt, the MPL Qt backend. Therefore they do not work with all (older) MatPlotLib versions…

Best,

Jorn

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub <

https://github.com/BoldingBruggeman/pyncview/issues/2?email_source=notifications&email_token=AC2RV6VHHJFZVUFLODPE5KTRFE44HA5CNFSM4K45NJQ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOENJEOZY#issuecomment-592594791

, or unsubscribe <

https://github.com/notifications/unsubscribe-auth/AC2RV6TZNNTGWR3UZKPWE2DRFE44HANCNFSM4K45NJQQ

.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub

https://github.com/BoldingBruggeman/pyncview/issues/2?email_source=notifications&email_token=ACVA42MUBRSSJ7NN65FVZVLRFUUF3A5CNFSM4K45NJQ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOENUDTZY#issuecomment-594033127, or unsubscribe

https://github.com/notifications/unsubscribe-auth/ACVA42OF7QRFCXCQ3KV4OBLRFUUF3ANCNFSM4K45NJQQ .

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/BoldingBruggeman/pyncview/issues/2?email_source=notifications&email_token=AC2RV6X2LAS2SQAW7YREYQTRFUWLRA5CNFSM4K45NJQ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOENUF66I#issuecomment-594042745, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC2RV6VADIJDQM5GK4U2BYTRFUWLRANCNFSM4K45NJQQ.

elmikh commented 3 years ago

Hi Knut, Jorn, Karsten and everybody interested,

I just had the same error recently, and I have found out the solution.

For the latest versions of Matplotlib (in my case I use Matplotlib 3.4.1) for Xmlplot package in mpl_backend_qt4.py file in the line 44 it you should change

if self._update_dpi(): to if self._update_figure_dpi():

then everything works smooth and fine.

Best, Elena

markusReinert commented 2 years ago

Hi,

thanks, Elena, for finding the solution! I have been struggling with this for quite some time.

It seems to me that in matplotlib 3.3.4 (and – I assume – in earlier versions, too), the method is called _update_dpi, but in matplotlib 3.4.1 (and newer versions), it is called _update_figure_dpi. While the method _update_figure_dpi also exists in matplotlib 3.3, it has a different effect there and does not scale the figure to the window size.

We should not ignore this issue, because people will update their matplotlib at one point, and then they will run into this problem (this happened to me). So I'm wondering what the best way to fix it would be.

  1. An easy solution would be to just make the change proposed by Elena. This would only cause problems for users that have the updated version of xmlplot but an old version of matplotlib. PyNcView would still be usable for them, only the figure would be smaller. One could, of course, require matplotlib 3.4.0 or newer, but this might be too restrictive.

  2. Another solution would be to put the call to _update_dpi into a "try except" construction, but this is probably not a nice solution for a function that is called a lot. Also, this might cause problems if matplotlib changes again.

  3. A third solution would be to explicitly check the version of matplotlib, and then use _update_dpi if the version number is less than 3.4.0 and otherwise _update_figure_dpi. I think this could work the best, but it is not a nice coding style, because we will then carry around an artifact of an old matplotlib version.

I'd be interested to hear your thoughts on this, @jornbr !

Best regards, Markus

markusReinert commented 2 years ago

It appears to me that this issue is solved with the newer versions of matplotlib. With matplotlib version 3.5, I have no problems with pyncview any more, and I did not need to do any of the proposed changes.

I suggest marking this issue as solved.