Pandas-Bokeh icon indicating copy to clipboard operation
Pandas-Bokeh copied to clipboard

Constant lines are splited

Open mosc9575 opened this issue 3 years ago • 4 comments

Environment Pandas 1.3.3 Python 3.9.7 pandas_bokeh 0.5.5

Problem When drawing constant lines in with pandas-bokeh it looks like there are multiple shorter lines instead on large on. When using a zoom tool this looks very odd.

import numpy as np
import pandas as pd
import pandas_bokeh

pandas_bokeh.output_notebook()
pd.set_option("plotting.backend", "pandas_bokeh")

df = pd.DataFrame({'x':7}, index=pd.RangeIndex(20))
df['y'] = df.index.values
df.loc[10:15,'y'] = 10
p = df.plot(kind='line')

bokeh_plot (1)

This problem was first mentioned on SO.

mosc9575 avatar Nov 18 '21 12:11 mosc9575

hi @mosc9575 ,

thanks for submitting this issue. this is indeed a weird behaviour and I have to look at the code why this happens. When I just plot this via Bokeh, I cannot see this behaviour:

image

PatrikHlobil avatar Dec 08 '21 13:12 PatrikHlobil

Hello, I was curious about this bug. So, I investigated a little into it and I found that this behavior is linked to the default parameter given to the creation of a figure: output_backend='webgl'

Hence, to reproduce this problem with "pure" bokeh you can use the following code where all parameters used are the same as in pandas_bokeh.

p = figure(title='', toolbar_location='right', active_scroll='wheel_zoom', plot_width=600, plot_height=400, output_backend='webgl', sizing_mode='fixed', x_axis_location='below', x_axis_label='')
p.line(df.index, df.x, legend_label=" x", color="#1f77b4")
p.line(df.index, df.y, legend_label=" y", color="#ff7f0e")
show(p)

By removing the output_backend='webgl' parameter, the issue is not there anymore. Maybe pandas_bokeh should not use the webgl backend by default?

vroger11 avatar Mar 23 '22 15:03 vroger11

Meanwhile, I added an issue on the bokeh repository: https://github.com/bokeh/bokeh/issues/12058

vroger11 avatar Mar 23 '22 16:03 vroger11

Meanwhile, I added an issue on the bokeh repository: bokeh/bokeh#12058

@vroger11 Your investigation is gold worth. Thanks a lot.

mosc9575 avatar Mar 26 '22 09:03 mosc9575