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
CGContextRef is NULL
of tight_layout
with MacOSX backend
#2654
Comments
Traceback:
|
Cc: @mdehoon |
Currently, tight_layout makes the layout tight but does not maintain tightness. So if I call tight_layout but then add a label to an axis or resize the figure, the layout will not be tight anymore (it will be either too tight or not tight enough). Is this how it is supposed to function? |
1 similar comment
Currently, tight_layout makes the layout tight but does not maintain tightness. So if I call tight_layout but then add a label to an axis or resize the figure, the layout will not be tight anymore (it will be either too tight or not tight enough). Is this how it is supposed to function? |
Btw the comment above is relevant for this bug. Depending on how tight_layout is supposed to function, the offending code may need to move to figure.draw. If so, it would be called from inside the event loop, and this bug would go away. |
My understanding has been that this is meant to be a one-shot function, to |
If tight_layout is redesigned, I'd be happy to help out in making sure that this bug doesn't reappear. This shouldn't be too hard: As long as the renderer is only used from inside the event loop callback (i.e., somewhere within the call to figure.draw), everything should be OK. The current tight_layout code on the other hand uses the renderer outside of figure.draw, which is causing this bug. |
Having the same problem here myself. Does anyone have any recommendations for alternative backends in OSX? PyQT is giving me some speed problems with ipython (
In case it matters, I am using conda. Thanks, Josh |
@ribonoous - I've generally used Tk when having problems with the other backends - it seems to nearly always work at least ok. Another option for the specific problem here is to do |
Tagging this as 1.5.x as this seems to involve a major re-write. Please re-milestone if I am wrong. |
See the following links for more info: matplotlib/matplotlib#2654 matplotlib/matplotlib#1852
a temporary solution |
I just add plt.show() before tight_layout() as below. And it works for me.
|
This may be related to #166, but has a quite different immediate cause, so I'm reporting it separately. It might be that I should instead report this in ipython, so feel free to redirect me there, if that's more appropriate
If I do the following in ipython started with
ipython -pylab=MacOSX
:I get a
CGContextRef is NULL
exception (full traceback in the first comment). The plot still appears, but it does not have the tight-layout applied. If I change the function instead to:it does work, with no exception.
Not that the same thing also happens if I use subplots instead of a single figure.
The text was updated successfully, but these errors were encountered: