【发布时间】:2016-04-11 10:19:24
【问题描述】:
我正在使用 Bokeh.Charts.Bar 创建条形图。我的问题是,我有一个 15 个标签的图例框,这个图例框覆盖了最右边的列(我使用的是 legend='top-right',如果我将其更改为 'top-left ',它将覆盖最左边的列)。所以我正在尝试创建一个图例对象(bokeh.models.annotations.legend)来设置 background_fill_data = 0、label_standoff、legend_pedding 等,以便移动图例框或使其透明,以便更容易创建图表.然而,到目前为止,我一无所获。非常感谢您的帮助。谢谢。
bar = Bar(result_df, values='Value', label='Label', legend='bottom_right',
stack='Stack', title="Title", bar_width=0.4,
color=color(columns='Stack', palette=self.get_colors(5), tools="pan,wheel_zoom,box_zoom,reset,resize,hover")
hover = bar.select(dict(type=HoverTool))
hover.tooltips=[("Stack", "@Stack"), (field_name, "@height{" + tooltip_fmt + "}")]
legend = Legend({
"background_fill_alpha": {
"value": 0
},
"background_fill_color": {
"value": "#ffffff"
},
"border_line_alpha": {
"value": 1.0
},
"border_line_cap": "butt",
"border_line_color": {
"value": "black"
},
"border_line_dash": [],
"border_line_dash_offset": 0,
"border_line_join": "miter",
"border_line_width": {
"value": 1
},
"glyph_height": 20,
"glyph_width": 20,
"label_height": 20,
"label_standoff": 15,
"label_text_align": "left",
"label_text_alpha": {
"value": 1.0
},
"label_text_baseline": "middle",
"label_text_color": {
"value": "#444444"
},
"label_text_font": "helvetica",
"label_text_font_size": {
"value": "10pt"
},
"label_text_font_style": "normal",
"label_width": 50,
"legend_padding": 10,
"legend_spacing": 3,
"legends": [],
"level": "annotation",
"location": "top_right"
})
bar.add_legend(legend)
【问题讨论】:
-
任何人都可以提供帮助或指出解决方案吗?
标签: python bar-chart legend bokeh