-
Notifications
You must be signed in to change notification settings - Fork 43
Description
I am able to run this code that converts a matplotlib plot into bokeh plot:
import numpy as np
import pandas as pd
from bokeh import mpl
from bokeh.plotting import output_file, show
ts = pd.Series(np.random.randn(1000), index=pd.date_range('1/1/2000', periods=1000))
ts = ts.cumsum()
df = pd.DataFrame(np.random.randn(1000, 4), index=ts.index, columns=list('ABCD'))
df = df.cumsum()
df.plot(legend=False)
output_file("dataframe.html")
show(mpl.to_bokeh())
But, when I try to run the code below, I get NotImplemetedError
#%matplotlib inline
import matplotlib.pyplot as plt
from bokeh import mpl
from bokeh.plotting import output_file, show
tt_grouped = df.groupby([df['CLIENT'],
pd.PeriodIndex(df.DATE_new, freq='M')])['EXECUTED_QUANTITY'].sum()
tt_grouped.unstack().plot(kind='bar',stacked=True,title="Title")
#plt.show()
output_file("dataframe.html")
show(mpl.to_bokeh())
Here is the error:
NotImplementedError Traceback (most recent call last)
in ()
9 output_file("dataframe.html")
10
---> 11 show(mpl.to_bokeh())
C:\Anaconda\lib\site-packages\bokeh\mpl.py in to_bokeh(fig, name, server, notebook, pd_obj, xkcd)
445 exporter = Exporter(renderer)
446
--> 447 exporter.run(fig)
448
449 doc._current_plot = renderer.fig # TODO (bev) do not rely on private attrs
C:\Anaconda\lib\site-packages\bokeh\mplexporter\exporter.py in run(self, fig)
48 import matplotlib.pyplot as plt
49 plt.close(fig)
---> 50 self.crawl_fig(fig)
51
52 @staticmethod
C:\Anaconda\lib\site-packages\bokeh\mplexporter\exporter.py in crawl_fig(self, fig)
115 props=utils.get_figure_properties(fig)):
116 for ax in fig.axes:
--> 117 self.crawl_ax(ax)
118
119 def crawl_ax(self, ax):
C:\Anaconda\lib\site-packages\bokeh\mplexporter\exporter.py in crawl_ax(self, ax)
135 self.draw_text(ax, artist)
136 for patch in ax.patches:
--> 137 self.draw_patch(ax, patch)
138 for collection in ax.collections:
139 self.draw_collection(ax, collection)
C:\Anaconda\lib\site-packages\bokeh\mplexporter\exporter.py in draw_patch(self, ax, patch, force_trans)
221 pathcodes=pathcodes,
222 style=linestyle,
--> 223 mplobj=patch)
224
225 def draw_collection(self, ax, collection,
C:\Anaconda\lib\site-packages\bokeh\mplexporter\renderers\base.py in draw_path(self, data, coordinates, pathcodes, style, offset, offset_coordinates, mplobj)
363 the matplotlib plot element which generated this path
364 """
--> 365 raise NotImplementedError()
366
367 def draw_image(self, imdata, extent, coordinates, style, mplobj=None):
NotImplementedError: