pythonpandasjupyter-notebookbokehpandas-bokeh

Constant values invisible in zoomed out bokeh line plot


I'm trying to create a line plot of a ~30.000 entries long array using pandas_bokeh in jupyter-notebook but constant values seem to be invisible when zoomet out.

When I further zoom in I can see that the data points are there but somehow dashed.

I tried the options provided on the pandas_bokeh github page: https://github.com/PatrikHlobil/Pandas-Bokeh#lineplot

My current workaround is to use the plot_data_points=True argument with very small square markers.

This is a minimum example to replicate the issue:

import numpy as np
import pandas as pd
import pandas_bokeh
pandas_bokeh.output_notebook()
pd.set_option("plotting.backend", "pandas_bokeh")

a = np.empty(2000)
a.fill(7)
test = pd.DataFrame(a, columns=['a'])
test.plot()

I'm using


Solution

  • This is truly a bug which should go to GitHub.

    I made a small modification to your exmaple

    import pandas as pd
    import pandas_bokeh
    
    df = pd.DataFrame({'a':7}, index=pd.RangeIndex(20))
    df['x'] = df.index
    df.plot_bokeh(kind='line')
    

    And the output it this:

    Same parameter set for both lines

    As you can see the figure draws different types of lines with the same parameter set for both lines.

    As long this is broken, you can use plain bokeh. To create this figure using bokeh, this is the example:

    from bokeh.plotting import show, figure, output_notebook
    output_notebook()
    
    p = figure(width=600, height=400)
    p.line(x='index', y='a', source=test)
    show(p)