-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
'Figure' object has no attribute '_original_dpi' #9040
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
Comments
maybe related to #8052 |
What sha are you at? #9002 went in yesterday and may have fixed this. |
I just pulled from master (20 min ago) |
From |
I can not reproduce this, I assume it has something to do some subtle ordering in when things are created and when things are attempted to be drawn. Does applying 20:00 $ git diff
diff --git a/lib/matplotlib/backends/backend_qt5agg.py b/lib/matplotlib/backends/backend_qt5agg.py
index 78d9fdada..85954c003 100644
--- a/lib/matplotlib/backends/backend_qt5agg.py
+++ b/lib/matplotlib/backends/backend_qt5agg.py
@@ -176,7 +176,7 @@ class FigureCanvasQTAggBase(FigureCanvasAgg):
self.draw()
-class FigureCanvasQTAgg(FigureCanvasQTAggBase, FigureCanvasQT):
+class FigureCanvasQTAgg(FigureCanvasQT, FigureCanvasQTAggBase):
"""
The canvas the figure renders into. Calls the draw and print fig
methods, creates the renderers, etc. help? |
@tacaswell no, I change the order and it doesn't help. The I think |
@tacaswell if I make the change in
Why it shows me the error in qt5? if it is qt4 in reality? |
Ah! Because the qt4 backend is a sub-class of the qt5 backend. The main differences between them are that qt5 is co-opperative and qt4 is not which mostly shows up in the |
import networkx
import matplotlib.backends.backend_qt4agg
def build_inheritance_graph(cls):
g = networkx.DiGraph()
todo = set([cls])
done = set()
while todo:
cls = todo.pop()
for b in cls.__bases__:
if b not in done:
todo.add(b)
g.add_edge(cls.__name__, b.__name__)
return g
g = build_inheritance_graph(matplotlib.backends.backend_qt5agg.FigureCanvas)
networkx.draw_networkx(g) will give you a visualization of the MI diagram from these classes (there are 3 diamonds, 1 from us, 1 from Qt and 1 from us + Qt back to |
def decorate_init(cls):
for b in cls.mro():
decorate(b)
def decorate(cls):
print(cls.__name__)
if cls is object:
return
if 'matplotlib' not in cls.__module__:
return
if '__init__' not in cls.__dict__:
return
orig_init = cls.__dict__['__init__']
def new_init(self, *args, **kwargs):
print(cls.__module__, cls.__name__)
return orig_init(self, *args, **kwargs)
cls.__init__ = new_init
decorate_init(matplotlib.backends.backend_qt4agg.FigureCanvas) Will trace through what get called. |
I have a patch that works but calls base class inits too many times.... |
in two places `super` needs to be used in the Qt5 case and frustrated in the Qt4 case. These are handled by the two `_fake_super_*` methods. The must be just private as we need to override in sub-classes. Closes matplotlib#9040
@tacaswell with the decorator
|
#9052 solves this problem |
closed by #9052 |
In 2.1.0 I still see this problem,
and with the decorator shown above I get
From the path above, you may also see versions used, pyqt is 5.9 (the latest). |
How did you install matplotlib? Are you using pyqt4 or pyqt5? |
Sorry about the 5.9, specification. This is the print-out at installation:
|
I just noticed that in fact it is using PyQt 5.9, as I initially wrote. If I do:
So I guess there is a bug in the QT_VERSION_STR, I will try and report this to their mailing list. |
Ahh, no, of course. QT is the parent library, while PYQT is the python wrapper qt. |
In fact, I believe this to be a bug in
while I guess it should read:
What do you think? |
I think you're right, would you submit a PR for that fix? Not sure what's going wrong with your original problem, unfortunately. |
@zerothi Do you still have this problem with 2.1.1? |
Closing as we can not reproduce this with 2.1.1. Please ping to be re-opened if you can still reproduce this issue with the current stable release. |
With current master, running any example
python3 histogram_cumulative.py
I get
It opens the window but the image is black
If I force to use a GTK3 backend I dont get the error and the figure is fine
The text was updated successfully, but these errors were encountered: