Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
624 views
in Technique[技术] by (71.8m points)

python - Bokeh LabelSet not displaying labels on vbar plot

I'm not quite sure what I'm missing here, I'm plotting a vbar comprised of categorical dates on the x-axis and a consumption value on the y-axis. The plot works fine but when I come to add labels, I don't get any errors but the values just aren't showing. Here's my code so far:

df = pd.read_csv(file)
total_day_cat = df.groupby(df['start'].dt.strftime("%d %b-%y")).sum().round(decimals=1).reset_index()
day_total_plot_data = ColumnDataSource(total_day_cat)

q = figure(plot_height=350, plot_width=1200, x_range=total_day_cat['start'], title="Total Daily Consumption",
           toolbar_location=None, tools="")
q_labels = LabelSet(x='start', y='consumption', text='consumption',
                    source=day_total_plot_data)
q.vbar(x='start', top='consumption', width=1, source=day_total_plot_data,
       line_color='black', fill_color='skyblue')

q.y_range.start = 0
q.xgrid.grid_line_color = None
q.xaxis.major_label_orientation = pi/4
q.yaxis[0].ticker.desired_num_ticks = 4
q.add_layout(q_labels)

show(q)

Here's the plot: Snippet of plot that's produced

Am I missing something really obvious here?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...