RuntimeError: CGContextRef is NULL

Thanks. Unfortunately wx and tk backends are broken on my machine (but they may be easier to fix).
I will file a bug report for the native backend bug.



On Oct 4, 2010, at 22:27 , Friedrich Romstedt wrote:

2010/10/4 Nicolas Rougier <Nicolas.Rougier@...2073...>:

I'm trying to have animated plots using draw_artist on mac os x and I got an error with the following script:

import numpy as np
import matplotlib.pyplot as plt

subplot = plt.subplot(1,1,1)
axis = plt.imshow(np.random.random((10,10)))

The traceback is:

Traceback (most recent call last):
File "", line 8, in <module>
File "/Volumes/Data/Local/lib/python2.7/site-packages/matplotlib/", line 1946, in draw_artist
File "/Volumes/Data/Local/lib/python2.7/site-packages/matplotlib/", line 55, in draw_wrapper
   draw(artist, renderer, *args, **kwargs)
File "/Volumes/Data/Local/lib/python2.7/site-packages/matplotlib/", line 338, in draw
   gc = renderer.new_gc()
File "/Volumes/Data/Local/lib/python2.7/site-packages/matplotlib/backends/", line 105, in new_gc
RuntimeError: CGContextRef is NULL

Is there something wrong in my script (it seems to be working on linux) ?

I don't know what it is, and it looks like some problem with the
Mac-native backend, but I believe you can sort it out by just
switching the backend to e.g. TkAgg.