Seaborn: Seaborn plots are not showing

Created on 6 Nov 2014  Â·  8Comments  Â·  Source: mwaskom/seaborn

None of the code examples (found throughout the gallery and the tutorial) seem to be producing plots. I'm not sure if I'm supposed to be doing a plt.show() command afterwards (which I've tried, and it gives me a really long traceback).

I'm using 'Seaborn 0.4.0', 'Matplotlib 1.4.0', with:

backend : macosx

question

Most helpful comment

You don't mention what context you're using, but just incase you're using
the IPython Notebook, you'll need to run %matplotlib inline in one of the
cells to display the plots inline.

On Thu, Nov 6, 2014 at 10:26 AM, Austen Groener [email protected]
wrote:

None of the code examples (found throughout the gallery and the tutorial)
seem to be producing plots. I'm not sure if I'm supposed to be doing a
plt.show() command afterwards (which I've tried, and it gives me a really
long traceback).

I'm using 'Seaborn 0.4.0', 'Matplotlib 1.4.0', with:

backend : macosx

—
Reply to this email directly or view it on GitHub
https://github.com/mwaskom/seaborn/issues/351.

All 8 comments

You don't mention what context you're using, but just incase you're using
the IPython Notebook, you'll need to run %matplotlib inline in one of the
cells to display the plots inline.

On Thu, Nov 6, 2014 at 10:26 AM, Austen Groener [email protected]
wrote:

None of the code examples (found throughout the gallery and the tutorial)
seem to be producing plots. I'm not sure if I'm supposed to be doing a
plt.show() command afterwards (which I've tried, and it gives me a really
long traceback).

I'm using 'Seaborn 0.4.0', 'Matplotlib 1.4.0', with:

backend : macosx

—
Reply to this email directly or view it on GitHub
https://github.com/mwaskom/seaborn/issues/351.

Right - I'm running it in a script.

You'll have to either show the figure or save it, no different from any other matplotlib plot. As for the traceback, hard to say without seeing it or knowing what example produced it, but I think the MacOSX backend has some problems particularly with tight_layout (which gets called by some of the plotters) so you could try a different backend...

Minimal example:

import seaborn as sns
sns.set(style="darkgrid")
tips = sns.load_dataset("tips")
color = sns.color_palette()[2]
g = sns.jointplot("total_bill", "tip", data=tips, kind="reg",
                  xlim=(0, 60), ylim=(0, 12), color=color, size=7)
import matplotlib.pyplot as plt
plt.show()

First I get this warning:

/Users/username/anaconda/lib/python2.7/site-packages/matplotlib/tight_layout.py:225: UserWarning: tight_layout : falling back to Agg renderer
  warnings.warn("tight_layout : falling back to Agg renderer")

Then the full traceback:

TypeError                                 Traceback (most recent call last)
/Users/username/anaconda/lib/python2.7/site-packages/matplotlib/artist.pyc in draw_wrapper(artist,     renderer, *args, **kwargs)
     57     def draw_wrapper(artist, renderer, *args, **kwargs):
     58         before(artist, renderer)
---> 59         draw(artist, renderer, *args, **kwargs)
     60         after(artist, renderer)
     61 

/Users/username/anaconda/lib/python2.7/site-packages/matplotlib/figure.pyc in draw(self, renderer)
   1077         dsu.sort(key=itemgetter(0))
   1078         for zorder, a, func, args in dsu:
-> 1079             func(*args)
   1080 
   1081         renderer.close_group('figure')

/Users/username/anaconda/lib/python2.7/site-packages/matplotlib/artist.pyc in draw_wrapper(artist,     renderer, *args, **kwargs)
     57     def draw_wrapper(artist, renderer, *args, **kwargs):
     58         before(artist, renderer)
---> 59         draw(artist, renderer, *args, **kwargs)
     60         after(artist, renderer)
     61 

/Users/username/anaconda/lib/python2.7/site-packages/matplotlib/axes/_base.pyc in draw(self,     renderer, inframe)
   2090 
   2091         for zorder, a in dsu:
-> 2092             a.draw(renderer)
   2093 
   2094         renderer.close_group('axes')

/Users/username/anaconda/lib/python2.7/site-packages/matplotlib/artist.pyc in draw_wrapper(artist,     renderer, *args, **kwargs)
     57     def draw_wrapper(artist, renderer, *args, **kwargs):
     58         before(artist, renderer)
---> 59         draw(artist, renderer, *args, **kwargs)
     60         after(artist, renderer)
     61 

/Users/username/anaconda/lib/python2.7/site-packages/matplotlib/axis.pyc in draw(self, renderer,     *args, **kwargs)
   1103         ticks_to_draw = self._update_ticks(renderer)
   1104         ticklabelBoxes, ticklabelBoxes2 = self._get_tick_bboxes(ticks_to_draw,
-> 1105                                                                 renderer)
   1106 
   1107         for tick in ticks_to_draw:

/Users/username/anaconda/lib/python2.7/site-packages/matplotlib/axis.pyc in _get_tick_bboxes(self,     ticks, renderer)
   1052         for tick in ticks:
   1053             if tick.label1On and tick.label1.get_visible():
-> 1054                 extent = tick.label1.get_window_extent(renderer)
   1055                 ticklabelBoxes.append(extent)
   1056             if tick.label2On and tick.label2.get_visible():

/Users/username/anaconda/lib/python2.7/site-packages/matplotlib/text.pyc in get_window_extent(self,     renderer, dpi)
    739             raise RuntimeError('Cannot get window extent w/o renderer')
    740 
--> 741         bbox, info, descent = self._get_layout(self._renderer)
    742         x, y = self.get_position()
    743         x, y = self.get_transform().transform_point((x, y))

/Users/username/anaconda/lib/python2.7/site-packages/matplotlib/text.pyc in _get_layout(self,     renderer)
    309         tmp, lp_h, lp_bl = renderer.get_text_width_height_descent('lp',
    310                                                          self._fontproperties,
--> 311                                                          ismath=False)
    312         offsety = (lp_h - lp_bl) * self._linespacing
    313 

/Users/username/anaconda/lib/python2.7/site-packages/matplotlib/backends/backend_macosx.pyc in     get_text_width_height_descent(self, s, prop, ismath)
    164         size = self.points_to_pixels(points)
    165         width, height, descent = self.gc.get_text_width_height_descent(
--> 166             six.text_type(s), family, size, weight, style)
    167         return  width, height, 0.0*descent
    168 

TypeError: bad argument type for built-in operation

It sure does.. Hmm. Let me try your initial recommendation and switch the backend.

Also, it appears that there might be a patch (https://github.com/matplotlib/matplotlib/pull/3564). Any ideas if it has made it's way into the current stable version of matplotlib? I'm trying to avoid having to grab the dev version..

That PR was closed before 1.4.2 was released, so yes, but there are other issues that may make you want to hold off upgrading (#344). FWIW I work mostly on OSX and don't run into this, though I do almost all my plotting in the IPython notebook.

Okay - simple fix: Upgrade to Matplotlib 1.4.2.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

TDaltonC picture TDaltonC  Â·  3Comments

amelio-vazquez-reina picture amelio-vazquez-reina  Â·  4Comments

queryous picture queryous  Â·  4Comments

ConstantinoSchillebeeckx picture ConstantinoSchillebeeckx  Â·  4Comments

phantom0301 picture phantom0301  Â·  3Comments