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

Seaborn plots are not showing #351

Closed
agroener opened this issue Nov 5, 2014 · 8 comments
Closed

Seaborn plots are not showing #351

agroener opened this issue Nov 5, 2014 · 8 comments
Labels

Comments

@agroener
Copy link

agroener commented Nov 5, 2014

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

@philsheard
Copy link

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 notifications@github.com
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
#351.

@agroener
Copy link
Author

agroener commented Nov 6, 2014

Right - I'm running it in a script.

@mwaskom
Copy link
Owner

mwaskom commented Nov 6, 2014

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...

@agroener
Copy link
Author

agroener commented Nov 7, 2014

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

@mwaskom
Copy link
Owner

mwaskom commented Nov 7, 2014

Sounds like matplotlib/matplotlib#3470

@agroener
Copy link
Author

agroener commented Nov 7, 2014

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

Also, it appears that there might be a patch (matplotlib/matplotlib#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..

@mwaskom
Copy link
Owner

mwaskom commented Nov 7, 2014

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.

@agroener
Copy link
Author

agroener commented Nov 7, 2014

Okay - simple fix: Upgrade to Matplotlib 1.4.2.

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

No branches or pull requests

3 participants