Skip to content

Commit 1143fe6

Browse files
committed
Add a placeholder for bokeh engine
1 parent 3e6716a commit 1143fe6

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

pandas/plotting/_core.py

+62
Original file line numberDiff line numberDiff line change
@@ -2458,6 +2458,65 @@ def _grouped_plot_by_column(plotf, data, columns=None, by=None,
24582458
return result
24592459

24602460

2461+
class BokehSeriesPlotMethods(base.SeriesPlotMethods):
2462+
2463+
@property
2464+
def engine_name(self):
2465+
return 'bokeh'
2466+
2467+
def __call__(**kwds):
2468+
import logging
2469+
logging.error(kwds)
2470+
2471+
2472+
class BokehFramePlotMethods(base.FramePlotMethods):
2473+
"""
2474+
repro notebook:
2475+
2476+
import pandas as pd
2477+
import numpy as np
2478+
import bokeh
2479+
from bokeh.io import output_notebook, INLINE
2480+
2481+
output_notebook(hide_banner=True)
2482+
pd.set_option('plotting.engine', 'bokeh')
2483+
df = pd.DataFrame(np.random.rand(5, 3), columns='foo bar baz'.split())
2484+
df.plot()
2485+
"""
2486+
2487+
@property
2488+
def engine_name(self):
2489+
return 'bokeh'
2490+
2491+
def __call__(self, x=None, y=None, kind='line', figure=None,
2492+
use_index=True, title=None, grid=None,
2493+
legend=True, style=None,
2494+
fontsize=None, colormap=None,
2495+
yerr=None, xerr=None,
2496+
secondary_y=False, sort_columns=False, **kwds):
2497+
2498+
from bokeh.plotting import Figure, show
2499+
from bokeh.models import ColumnDataSource, HoverTool
2500+
2501+
df = self._data
2502+
source = ColumnDataSource(df)
2503+
hover_tool = HoverTool(
2504+
tooltips=[
2505+
('index', '$index'),
2506+
('(x,y)', '($x, $y)'),
2507+
]
2508+
)
2509+
plot = Figure(
2510+
width=450,
2511+
height=300,
2512+
logo=None,
2513+
tools=[hover_tool]
2514+
)
2515+
for column in df.columns:
2516+
plot.line(x='index', y=column, source=source);
2517+
return show(plot)
2518+
2519+
24612520
class MPLSeriesPlotMethods(base.SeriesPlotMethods):
24622521
"""Series plotting accessor and method
24632522
@@ -2845,3 +2904,6 @@ def hexbin(self, x, y, C=None, reduce_C_function=None, gridsize=None,
28452904

28462905
base.register_engine("matplotlib", 'series', MPLSeriesPlotMethods)
28472906
base.register_engine("matplotlib", 'frame', MPLFramePlotMethods)
2907+
2908+
base.register_engine('bokeh', 'series', BokehSeriesPlotMethods)
2909+
base.register_engine('bokeh', 'frame', BokehFramePlotMethods)

0 commit comments

Comments
 (0)