PatrikHlobil / Pandas-Bokeh

Bokeh Plotting Backend for Pandas and GeoPandas
MIT License
879 stars 112 forks source link

Constant lines are splited #117

Open mosc9575 opened 3 years ago

mosc9575 commented 3 years ago

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.

PatrikHlobil commented 2 years ago

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

vroger11 commented 2 years ago

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 commented 2 years ago

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

mosc9575 commented 2 years ago

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

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