Closed
Description
Running the following command with plotnine 0.3.0:
(
plotnine.ggplot(plotnine.aes(x='year', fill='mode_style'), data=biblio_df) +
plotnine.geom_histogram(binwidth=1, color='white') +
plotnine.scale_x_continuous(minor_breaks=None) +
plotnine.coord_cartesian(xlim=(2000, 2017), expand=False)
)
Results in the following error / traceback:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
~/anaconda3/envs/pmc-citation-styles/lib/python3.6/site-packages/IPython/core/formatters.py in __call__(self, obj)
700 type_pprinters=self.type_printers,
701 deferred_pprinters=self.deferred_printers)
--> 702 printer.pretty(obj)
703 printer.flush()
704 return stream.getvalue()
~/anaconda3/envs/pmc-citation-styles/lib/python3.6/site-packages/IPython/lib/pretty.py in pretty(self, obj)
393 if callable(meth):
394 return meth(obj, self, cycle)
--> 395 return _default_pprint(obj, self, cycle)
396 finally:
397 self.end_group()
~/anaconda3/envs/pmc-citation-styles/lib/python3.6/site-packages/IPython/lib/pretty.py in _default_pprint(obj, p, cycle)
508 if _safe_getattr(klass, '__repr__', None) is not object.__repr__:
509 # A user-provided repr. Find newlines and replace them with p.break_()
--> 510 _repr_pprint(obj, p, cycle)
511 return
512 p.begin_group(1, '<')
~/anaconda3/envs/pmc-citation-styles/lib/python3.6/site-packages/IPython/lib/pretty.py in _repr_pprint(obj, p, cycle)
699 """A pprint that just redirects to the normal repr function."""
700 # Find newlines and replace them with p.break_()
--> 701 output = repr(obj)
702 for idx,output_line in enumerate(output.splitlines()):
703 if idx:
~/anaconda3/envs/pmc-citation-styles/lib/python3.6/site-packages/plotnine/ggplot.py in __repr__(self)
84 Print/show the plot
85 """
---> 86 self.draw()
87 plt.show()
88 return '<ggplot: (%d)>' % self.__hash__()
~/anaconda3/envs/pmc-citation-styles/lib/python3.6/site-packages/plotnine/ggplot.py in draw(self, return_ggplot)
201 if self.figure is not None:
202 plt.close(self.figure)
--> 203 raise err
204
205 if return_ggplot:
~/anaconda3/envs/pmc-citation-styles/lib/python3.6/site-packages/plotnine/ggplot.py in draw(self, return_ggplot)
191 # Drawing
192 self._draw_layers()
--> 193 self._draw_facet_labels()
194 self._draw_labels()
195 self._draw_legend()
~/anaconda3/envs/pmc-citation-styles/lib/python3.6/site-packages/plotnine/ggplot.py in _draw_facet_labels(self)
389 panel_params = self.layout.panel_params[pidx]
390 self.facet.set_breaks_and_labels(
--> 391 panel_params, layout_info, pidx)
392 self.facet.draw_label(layout_info, pidx)
393
~/anaconda3/envs/pmc-citation-styles/lib/python3.6/site-packages/plotnine/facets/facet_null.py in set_breaks_and_labels(self, ranges, layout_info, pidx)
41 """
42 ax = self.axs[pidx]
---> 43 facet.set_breaks_and_labels(self, ranges, layout_info, pidx)
44 ax.xaxis.set_ticks_position('bottom')
45 ax.yaxis.set_ticks_position('left')
~/anaconda3/envs/pmc-citation-styles/lib/python3.6/site-packages/plotnine/facets/facet.py in set_breaks_and_labels(self, ranges, layout_info, pidx)
253
254 # minor breaks
--> 255 ax.set_xticks(ranges['x_minor'], minor=True)
256 ax.set_yticks(ranges['y_minor'], minor=True)
257
~/anaconda3/envs/pmc-citation-styles/lib/python3.6/site-packages/matplotlib/axes/_base.py in set_xticks(self, ticks, minor)
3045 Default is ``False``.
3046 """
-> 3047 ret = self.xaxis.set_ticks(ticks, minor=minor)
3048 self.stale = True
3049 return ret
~/anaconda3/envs/pmc-citation-styles/lib/python3.6/site-packages/matplotlib/axis.py in set_ticks(self, ticks, minor)
1642 # XXX if the user changes units, the information will be lost here
1643 ticks = self.convert_units(ticks)
-> 1644 if len(ticks) > 1:
1645 xleft, xright = self.get_view_interval()
1646 if xright > xleft:
TypeError: object of type 'NoneType' has no len()
As a workaround I can set minor_breaks=[0]
(something out of the viewable range).