In [10]:
import pandas as pd
import seaborn as sns
%matplotlib inline

predicted_counts = pd.read_csv('https://raw.githubusercontent.com/olgabot/seaborn_factorplot_pointplot_valueerror/master/predicted_counts.csv')
predicted_counts.head()


Out[10]:
Original Modality Predicted Modality Noise Features Percent of Features
0 bimodal bimodal 0 1 100
1 bimodal bimodal 10 100 100
2 bimodal bimodal 20 100 100
3 bimodal bimodal 30 69 69
4 bimodal bimodal 40 12 12

No error with kind="bar"


In [11]:
g = sns.factorplot(x='Noise', hue='Predicted Modality', y='Percent of Features', 
               col='Original Modality', 
               data=predicted_counts, kind='bar', 
                   col_wrap=2, 
                   aspect=1.5, legend=False)


kind="point" gives a ValueError


In [12]:
g = sns.factorplot(x='Noise', hue='Predicted Modality', y='Percent of Features', 
               col='Original Modality', 
               data=predicted_counts, kind='point', 
                   col_wrap=2, 
#                hue_order=MODALITY_ORDER, 
#                palette=MODALITY_PALETTE, 
                   aspect=1.5, legend=False)


---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/Users/olga/anaconda/lib/python2.7/site-packages/IPython/core/formatters.pyc in __call__(self, obj)
    335                 pass
    336             else:
--> 337                 return printer(obj)
    338             # Finally look for special method names
    339             method = _safe_get_formatter_method(obj, self.print_method)

/Users/olga/anaconda/lib/python2.7/site-packages/IPython/core/pylabtools.pyc in <lambda>(fig)
    205 
    206     if 'png' in formats:
--> 207         png_formatter.for_type(Figure, lambda fig: print_figure(fig, 'png', **kwargs))
    208     if 'retina' in formats or 'png2x' in formats:
    209         png_formatter.for_type(Figure, lambda fig: retina_figure(fig, **kwargs))

/Users/olga/anaconda/lib/python2.7/site-packages/IPython/core/pylabtools.pyc in print_figure(fig, fmt, bbox_inches, **kwargs)
    115 
    116     bytes_io = BytesIO()
--> 117     fig.canvas.print_figure(bytes_io, **kw)
    118     data = bytes_io.getvalue()
    119     if fmt == 'svg':

/Users/olga/anaconda/lib/python2.7/site-packages/matplotlib/backend_bases.pyc in print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, **kwargs)
   2156                     orientation=orientation,
   2157                     dryrun=True,
-> 2158                     **kwargs)
   2159                 renderer = self.figure._cachedRenderer
   2160                 bbox_inches = self.figure.get_tightbbox(renderer)

/Users/olga/anaconda/lib/python2.7/site-packages/matplotlib/backends/backend_agg.pyc in print_png(self, filename_or_obj, *args, **kwargs)
    519 
    520     def print_png(self, filename_or_obj, *args, **kwargs):
--> 521         FigureCanvasAgg.draw(self)
    522         renderer = self.get_renderer()
    523         original_dpi = renderer.dpi

/Users/olga/anaconda/lib/python2.7/site-packages/matplotlib/backends/backend_agg.pyc in draw(self)
    467 
    468         try:
--> 469             self.figure.draw(self.renderer)
    470         finally:
    471             RendererAgg.lock.release()

/Users/olga/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/olga/anaconda/lib/python2.7/site-packages/matplotlib/figure.pyc in draw(self, renderer)
   1083         dsu.sort(key=itemgetter(0))
   1084         for zorder, a, func, args in dsu:
-> 1085             func(*args)
   1086 
   1087         renderer.close_group('figure')

/Users/olga/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/olga/anaconda/lib/python2.7/site-packages/matplotlib/axes/_base.pyc in draw(self, renderer, inframe)
   2108 
   2109         for zorder, a in dsu:
-> 2110             a.draw(renderer)
   2111 
   2112         renderer.close_group('axes')

/Users/olga/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/olga/anaconda/lib/python2.7/site-packages/matplotlib/collections.pyc in draw(self, renderer)
    770     def draw(self, renderer):
    771         self.set_sizes(self._sizes, self.figure.dpi)
--> 772         Collection.draw(self, renderer)
    773 
    774 

/Users/olga/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/olga/anaconda/lib/python2.7/site-packages/matplotlib/collections.pyc in draw(self, renderer)
    257         renderer.open_group(self.__class__.__name__, self.get_gid())
    258 
--> 259         self.update_scalarmappable()
    260 
    261         transform, transOffset, offsets, paths = self._prepare_points()

/Users/olga/anaconda/lib/python2.7/site-packages/matplotlib/collections.pyc in update_scalarmappable(self)
    670             return
    671         if self._A.ndim > 1:
--> 672             raise ValueError('Collections can only map rank 1 arrays')
    673         if not self.check_update("array"):
    674             return

ValueError: Collections can only map rank 1 arrays
<matplotlib.figure.Figure at 0x10d6ae690>

FacetGrid + mapping pointplot don't plot the full extent of the x-axis


In [13]:
g = sns.FacetGrid(predicted_counts, col='Original Modality', hue="Predicted Modality", col_wrap=2)
g.map(sns.pointplot, 'Noise', 'Percent of Features')


Out[13]:
<seaborn.axisgrid.FacetGrid at 0x10c8c7610>

Manually set xlim=(0, 100) (the true xlim)


In [14]:
g = sns.FacetGrid(predicted_counts, col='Original Modality', hue="Predicted Modality", col_wrap=2)
g.map(sns.pointplot, 'Noise', 'Percent of Features')
g.set(xlim=(0, 100))


Out[14]:
<seaborn.axisgrid.FacetGrid at 0x11064af90>

In [ ]: