Uploaded image for project: 'Zeppelin'
  1. Zeppelin
  2. ZEPPELIN-4096

Matplotlib error when trying to plot some dates

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 0.8.1
    • None
    • pySpark
    • None

    Description

      Hello team, 

      I have a problem for one of my script in which I'd like to plot with matplotlib a Dataframe with datetime on the x axis. I've tried even with a very simple Dataframe and there is always an exception raised.

      This is the script you can try runing: 

      import matplotlib
      import numpy
      import pandas as pd
      new_df = pd.DataFrame(data={"date":[strToDateTime("2019-03-01"), strToDateTime("2019-03-02"), strToDateTime("2019-03-03"), strToDateTime("2019-03-04")], "metrics":[1, 2, 3, 4]})
      new_df.plot(x="date")
      

      And here is the error message : 

      Traceback (most recent call last): File "/tmp/zeppelin_pyspark-723464616573853530.py", line 367, in <module> raise Exception(traceback.format_exc()) Exception: Traceback (most recent call last): File "/tmp/zeppelin_pyspark-723464616573853530.py", line 360, in <module> exec(code, _zcUserQueryNameSpace) File "<stdin>", line 2, in <module> File "/usr/lib64/python2.7/site-packages/pandas/plotting/_core.py", line 2941, in __call__ sort_columns=sort_columns, **kwds) File "/usr/lib64/python2.7/site-packages/pandas/plotting/_core.py", line 1977, in plot_frame **kwds) File "/usr/lib64/python2.7/site-packages/pandas/plotting/_core.py", line 1804, in _plot plot_obj.generate() File "/usr/lib64/python2.7/site-packages/pandas/plotting/_core.py", line 260, in generate self._make_plot() File "/usr/lib64/python2.7/site-packages/pandas/plotting/_core.py", line 985, in _make_plot **kwds) File "/usr/lib64/python2.7/site-packages/pandas/plotting/_core.py", line 1024, in _ts_plot lines = cls._plot(ax, data.index, data.values, style=style, **kwds) File "/usr/lib64/python2.7/site-packages/pandas/plotting/_core.py", line 1001, in _plot lines = MPLPlot._plot(ax, x, y_values, style=style, **kwds) File "/usr/lib64/python2.7/site-packages/pandas/plotting/_core.py", line 615, in _plot return ax.plot(*args, **kwds) File "/usr/lib64/python2.7/site-packages/matplotlib/__init__.py", line 1855, in inner return func(ax, *args, **kwargs) File "/usr/lib64/python2.7/site-packages/matplotlib/axes/_axes.py", line 1527, in plot for line in self._get_lines(*args, **kwargs): File "/usr/lib64/python2.7/site-packages/matplotlib/axes/_base.py", line 406, in _grab_next_args for seg in self._plot_args(this, kwargs): File "/usr/lib64/python2.7/site-packages/matplotlib/axes/_base.py", line 383, in _plot_args x, y = self._xy_from_xy(x, y) File "/usr/lib64/python2.7/site-packages/matplotlib/axes/_base.py", line 215, in _xy_from_xy bx = self.axes.xaxis.update_units(x) File "/usr/lib64/python2.7/site-packages/matplotlib/axis.py", line 1474, in update_units self._update_axisinfo() File "/usr/lib64/python2.7/site-packages/matplotlib/axis.py", line 1492, in _update_axisinfo self.set_major_locator(info.majloc) File "/usr/lib64/python2.7/site-packages/matplotlib/axis.py", line 1597, in set_major_locator self.stale = True File "/usr/lib64/python2.7/site-packages/matplotlib/artist.py", line 241, in stale self.stale_callback(self, val) File "/usr/lib64/python2.7/site-packages/matplotlib/artist.py", line 68, in _stale_axes_callback self.axes.stale = val File "/usr/lib64/python2.7/site-packages/matplotlib/artist.py", line 241, in stale self.stale_callback(self, val) File "/usr/lib64/python2.7/site-packages/matplotlib/figure.py", line 60, in _stale_figure_callback self.figure.stale = val File "/usr/lib64/python2.7/site-packages/matplotlib/artist.py", line 241, in stale self.stale_callback(self, val) File "/usr/lib64/python2.7/site-packages/matplotlib/pyplot.py", line 592, in _auto_draw_if_interactive fig.canvas.draw_idle() File "/opt/zeppelin/interpreter/lib/python/backend_zinline.py", line 136, in draw_idle self.draw(*args, **kwargs) File "/usr/lib64/python2.7/site-packages/matplotlib/backends/backend_agg.py", line 433, in draw self.figure.draw(self.renderer) File "/usr/lib64/python2.7/site-packages/matplotlib/artist.py", line 55, in draw_wrapper return draw(artist, renderer, *args, **kwargs) File "/usr/lib64/python2.7/site-packages/matplotlib/figure.py", line 1475, in draw renderer, self, artists, self.suppressComposite) File "/usr/lib64/python2.7/site-packages/matplotlib/image.py", line 141, in _draw_list_compositing_images a.draw(renderer) File "/usr/lib64/python2.7/site-packages/matplotlib/artist.py", line 55, in draw_wrapper return draw(artist, renderer, *args, **kwargs) File "/usr/lib64/python2.7/site-packages/matplotlib/axes/_base.py", line 2607, in draw mimage._draw_list_compositing_images(renderer, self, artists) File "/usr/lib64/python2.7/site-packages/matplotlib/image.py", line 141, in _draw_list_compositing_images a.draw(renderer) File "/usr/lib64/python2.7/site-packages/matplotlib/artist.py", line 55, in draw_wrapper return draw(artist, renderer, *args, **kwargs) File "/usr/lib64/python2.7/site-packages/matplotlib/axis.py", line 1190, in draw ticks_to_draw = self._update_ticks(renderer) File "/usr/lib64/python2.7/site-packages/matplotlib/axis.py", line 1028, in _update_ticks tick_tups = list(self.iter_ticks()) # iter_ticks calls the locator File "/usr/lib64/python2.7/site-packages/matplotlib/axis.py", line 971, in iter_ticks majorLocs = self.major.locator() File "/usr/lib64/python2.7/site-packages/matplotlib/dates.py", line 1249, in __call__ self.refresh() File "/usr/lib64/python2.7/site-packages/matplotlib/dates.py", line 1269, in refresh dmin, dmax = self.viewlim_to_dt() File "/usr/lib64/python2.7/site-packages/matplotlib/dates.py", line 1026, in viewlim_to_dt .format(vmin)) ValueError: view limit minimum 0.0 is less than 1 and is an invalid Matplotlib date value. This often happens if you pass a non-datetime value to an axis that has datetime units
       
      

      I have tried to run this script directly on Python on the terminal as well as on a Jupyter notebook and it worked, that is why I think it is an isue coming directly from Zeppelin.

      Thank you for you help 

      Attachments

        Activity

          People

            Unassigned Unassigned
            henri.chabert Henri Chabert
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated: