8000 RuntimeError: CGContextRef is NULL with draw_artist · Issue #166 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
RuntimeError: CGContextRef is NULL with draw_artist #166
Closed
@ddale

Description

@ddale

Original report at SourceForge, opened Mon Oct 4 17:04:36 2010

draw_artist on mac os x gives me an error with the following script:

import numpy as np
import matplotlib.pyplot as plt

plt.ion()
plt.figure()
subplot = plt.subplot(1,1,1)
axis = plt.imshow(np.random.random((10,10)))
plt.draw()
subplot.draw_artist(axis)
plt.show()

The traceback is:

Traceback (most recent call last):
File "matplotlib-bug.py", line 8, in
subplot.draw_artist(axis)
File "/Volumes/Data/Local/lib/python2.7/site-packages/matplotlib/axes.py", line 1946, in draw_artist
a.draw(self._cachedRenderer)
File "/Volumes/Data/Local/lib/python2.7/site-packages/matplotlib/artist.py", line 55, in draw_wrapper
draw(artist, renderer, _args, *_kwargs)
File "/Volumes/Data/Local/lib/python2.7/site-packages/matplotlib/image.py", line 338, in draw
gc = renderer.new_gc()
File "/Volumes/Data/Local/lib/python2.7/site-packages/matplotlib/backends/backend_macosx.py", line 105, in new_gc
self.gc.save()
RuntimeError: CGContextRef is NULL

matplotlib version: 1.0.0 (compiled)
python version 2.7 (binary from python.org)
macosx version: 10.6.4

SourceForge Comments

On Tue Oct 5 02:39:48 2010, nicolasrougier wrote:

I got the code from the "Animating selected plot elements" from the scipy cookbook page on animation.
The reason for this code is that I've several subplots to be drawn while I'm running the simulation. I could have used a simple call to plt.draw() but this would redraw the whole figure (is that right ?) and thus I tried to restrict the re-drawing to changing elements since the display is quite slow compared to simualtion.
The same code seems to be working on linux using the gtk backend but maybe it is not supposed to.

On Tue Oct 5 01:31:15 2010, mdehoon wrote:

I think what is happening is that graphics context functions are being called outside of the event loop. This will not work (at least not in the Mac OS X backend), since the graphics context (CGContextRef) is initialized inside the event loop. What exactly are you trying to accomplish? Can you show a full script that you would like to use for your animations? Also, is this script shown in the matplotlib documentation somewhere?

SourceForge History

  • On Tue Oct 5 01:31:15 2010, by mdehoon: assigned_to: 100

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0