Skip to content
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

Unable to run tutorial: RuntimeError: CGContextRef is NULL #491

Closed
amelio-vazquez-reina opened this issue Feb 11, 2014 · 1 comment
Closed

Comments

@amelio-vazquez-reina
Copy link

NOTE: This issue seems to be specific to OS X. See matplotlib/matplotlib#166 and matplotlib/matplotlib#2654

When running the tutorial I get the following error when plotting the trace of the samples:

In [2]: pm.traceplot(trace);
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-2-a3b0fe40351f> in <module>()
----> 1 pm.traceplot(trace);

/Users/josh/anaconda/envs/py27/lib/python2.7/site-packages/pymc/plots.pyc in traceplot(trace, vars, figsize, lines, combined, grid)
     77                     pass
     78 
---> 79     plt.tight_layout()
     80     return fig
     81 

/Users/josh/anaconda/envs/py27/lib/python2.7/site-packages/matplotlib/pyplot.pyc in tight_layout(pad, h_pad, w_pad, rect)
   1253 
   1254     fig = gcf()
-> 1255     fig.tight_layout(pad=pad, h_pad=h_pad, w_pad=w_pad, rect=rect)
   1256     draw_if_interactive()
   1257 

/Users/josh/anaconda/envs/py27/lib/python2.7/site-packages/matplotlib/figure.pyc in tight_layout(self, renderer, pad, h_pad, w_pad, rect)
   1603                                          renderer,
   1604                                          pad=pad, h_pad=h_pad, w_pad=w_pad,
-> 1605                                          rect=rect)
   1606 
   1607         self.subplots_adjust(**kwargs)

/Users/josh/anaconda/envs/py27/lib/python2.7/site-packages/matplotlib/tight_layout.pyc in get_tight_layout_figure(fig, axes_list, subplotspec_list, renderer, pad, h_pad, w_pad, rect)
    350                                      subplot_list=subplot_list,
    351                                      ax_bbox_list=ax_bbox_list,
--> 352                                      pad=pad, h_pad=h_pad, w_pad=w_pad)
    353 
    354     if rect is not None:

/Users/josh/anaconda/envs/py27/lib/python2.7/site-packages/matplotlib/tight_layout.pyc in auto_adjust_subplotpars(fig, renderer, nrows_ncols, num1num2_list, subplot_list, ax_bbox_list, pad, h_pad, w_pad, rect)
    127         #ax_bbox = union([ax.get_position(original=True) for ax in subplots])
    128 
--> 129         tight_bbox_raw = union([ax.get_tightbbox(renderer) for ax in subplots])
    130         tight_bbox = TransformedBbox(tight_bbox_raw,
    131                                      fig.transFigure.inverted())

/Users/josh/anaconda/envs/py27/lib/python2.7/site-packages/matplotlib/axes.pyc in get_tightbbox(self, renderer, call_axes_locator)
   9151 
   9152         if self.title.get_visible():
-> 9153             bb.append(self.title.get_window_extent(renderer))
   9154         if self._left_title.get_visible():
   9155             bb.append(self._left_title.get_window_extent(renderer))

/Users/josh/anaconda/envs/py27/lib/python2.7/site-packages/matplotlib/text.pyc in get_window_extent(self, renderer, dpi)
    752             raise RuntimeError('Cannot get window extent w/o renderer')
    753 
--> 754         bbox, info, descent = self._get_layout(self._renderer)
    755         x, y = self.get_position()
    756         x, y = self.get_transform().transform_point((x, y))

/Users/josh/anaconda/envs/py27/lib/python2.7/site-packages/matplotlib/text.pyc in _get_layout(self, renderer)
    318         tmp, lp_h, lp_bl = get_text_width_height_descent('lp',
    319                                                          self._fontproperties,
--> 320                                                          ismath=False)
    321         offsety = (lp_h - lp_bl) * self._linespacing
    322 

/Users/josh/anaconda/envs/py27/lib/python2.7/site-packages/matplotlib/backends/backend_macosx.pyc in get_text_width_height_descent(self, s, prop, ismath)
    156         points = prop.get_size_in_points()
    157         size = self.points_to_pixels(points)
--> 158         width, height, descent = self.gc.get_text_width_height_descent(unicode(s), family, size, weight, style)
    159         return  width, height, 0.0*descent
    160 

RuntimeError: CGContextRef is NULL

This is all with Python 2.7.6 with a conda installation.

@jsalvatier
Copy link
Member

I don't know what's causing this, but it looks like a matplotlib issue
related to this one (matplotlib/matplotlib#2654).

On Tue, Feb 11, 2014 at 2:53 PM, ribonoous notifications@github.com wrote:

When running the tutorialhttp://nbviewer.ipython.org/github/pymc-devs/pymc/blob/master/pymc/examples/tutorial.ipynbI get the following error when plotting the trace of the samples:

In [2]: pm.traceplot(trace);---------------------------------------------------------------------------RuntimeError Traceback (most recent call last) in ()----> 1 pm.traceplot(trace);
/Users/josh/anaconda/envs/py27/lib/python2.7/site-packages/pymc/plots.pyc in traceplot(trace, vars, figsize, lines, combined, grid)
77 pass
78 ---> 79 plt.tight_layout()
80 return fig
81
/Users/josh/anaconda/envs/py27/lib/python2.7/site-packages/matplotlib/pyplot.pyc in tight_layout(pad, h_pad, w_pad, rect)
1253
1254 fig = gcf()-> 1255 fig.tight_layout(pad=pad, h_pad=h_pad, w_pad=w_pad, rect=rect)
1256 draw_if_interactive()
1257
/Users/josh/anaconda/envs/py27/lib/python2.7/site-packages/matplotlib/figure.pyc in tight_layout(self, renderer, pad, h_pad, w_p
ad, rect)
1603 renderer,
1604 pad=pad, h_pad=h_pad, w_pad=w_pad,-> 1605 rect=rect)
1606
1607 self.subplots_adjust(*_kwargs)
/Users/josh/anaconda/envs/py27/lib/python2.7/site-packages/matplotlib/tight_layout.pyc in get_tight_layout_figure(fig, axes_list, subplotspec_list, renderer, pad, h_pad, w_pad, rect)
350 subplot_list=subplot_list,
351 ax_bbox_list=ax_bbox_list,--> 352 pad=pad, h_pad=h_pad, w_pad=w_pad)
353
354 if rect is not None:
/Users/josh/anaconda/envs/py27/lib/python2.7/site-packages/matplotlib/tight_layout.pyc in auto_adjust_subplotpars(fig, renderer, nrows_ncols, num1num2_list, subplot_list, ax_bbox_list, pad, h_pad, w_pad, rect)
127 #ax_bbox = union([ax.get_position(original=True) for ax in subplots])
128 --> 129 tight_bbox_raw = union([ax.get_tightbbox(renderer) for ax in subplots])
130 tight_bbox = TransformedBbox(tight_bbox_raw,
131 fig.transFigure.inverted())
/Users/josh/anaconda/envs/py27/lib/python2.7/site-packages/matplotlib/axes.pyc in get_tightbbox(self, renderer, call_axes_locator)
9151
9152 if self.title.get_visible():-> 9153 bb.append(self.title.get_window_extent(renderer))
9154 if self._left_title.get_visible():
9155 bb.append(self._left_title.get_window_extent(renderer))
/Users/josh/anaconda/envs/py27/lib/python2.7/site-packages/matplotlib/text.pyc in get_window_extent(self, renderer, dpi)
752 raise RuntimeError('Cannot get window extent w/o renderer')
753 --> 754 bbox, info, descent = self._get_layout(self._renderer)
755 x, y = self.get_position()
756 x, y = self.get_transform().transform_point((x, y))
/Users/josh/anaconda/envs/py27/lib/python2.7/site-packages/matplotlib/text.pyc in _get_layout(self, renderer)
318 tmp, lp_h, lp_bl = get_text_width_height_descent('lp',
319 self._fontproperties,--> 320 ismath=False)
321 offsety = (lp_h - lp_bl) * self._linespacing
322
/Users/josh/anaconda/envs/py27/lib/python2.7/site-packages/matplotlib/backends/backend_macosx.pyc in get_text_width_height_descent(self, s, prop, ismath)
156 points = prop.get_size_in_points()
157 size = self.points_to_pixels(points)--> 158 width, height, descent = self.gc.get_text_width_height_descent(unicode(s), family, size, weight, style)
159 return width, height, 0.0_descent
160
RuntimeError: CGContextRef is NULL

This is all with Python 2.7.6 with a conda installation.

Reply to this email directly or view it on GitHubhttps://github.com//issues/491
.

@twiecki twiecki closed this as completed Aug 17, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants