I came across one problem I couldn't find a solution. I would like to change the bar width of my plot, but doesn't matter the number I put in the WIDTH parameter of the method vbar, the graph remains the same.
The plot with WIDTH=100
The plot with WIDTH=500
Apply Zoom is not a solution. The bar seems like a line
Here is the code:
from bokeh.io import show, output_file
from bokeh.plotting import figure
import pandas as pd
df = pd.read_csv('Data/moviments.txt', delimiter='\t', encoding='utf-8')
output_file("bar_basic.html")
df['DT']=pd.to_datetime(df['DT'])
p = figure(x_axis_type='datetime',
plot_width=1230,
plot_height=500,
title='Moviments')
p.vbar(x=df['DT'],top=df['SUM_IN'], width=100, fill_alpha=0.8, color='green')
p.vbar(x=df['DT'],top=df['SUM_OUT'], width=100, fill_alpha=0.8, color='red')
p.xgrid.grid_line_color = None
show(p)
That is the info of my dataframe:
RangeIndex: 133 entries, 0 to 132 Data columns (total 5 columns): DT 133 non-null datetime64[ns] TRANSACT_IN 133 non-null int64 TRANSACT_OUT
133 non-null int64 SUM_IN 133 non-null int64 SUM_OUT
133 non-null int64 dtypes: datetime64ns, int64(4)
The underlying scale on datetime axes is milliseconds-since-epoch. So, currently you are looking at bars 500ms wide across a scale of months. You need to make the bars much wider. For instance, a bar "one day" wide would need:
width=24*60*60*1000 # 86400000
Alternatively with recent Bokeh versions you can also use a datetime.timedelta
, e.g.
width=timedelta(days=1)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With