如何在bokeh中显示补丁的图例项 [英] how to show legend items of patches in bokeh

查看:69
本文介绍了如何在bokeh中显示补丁的图例项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在以下设置中,我将基于基本示例创建一个面积图.如何自动或以编程方式获取图例以供输入.现在,我只得到带有一个项目"a"和第一个颜色的图例.

In the following set up, I create a area chart based on the basic example. How do I get the legend for my input automatically or even programatically. For now I get only legend with one item 'a' and the first color.

from bokeh.plotting import *

...
patches([x2 for a in areas], list(areas.values()), color=colors, alpha=0.8,
    line_color=None, legend='a', title="hello chart")

legend().orientation = "top_right" # what other options, may here?
show()

要传递给图例的补丁作为值的格式是什么?我该如何触发legend()为图中的每个项目显示一个项目和颜色?

What is the format to pass into patches for the legend as value or how can I trigger the legend() to show an item and color for every item in the plot?

推荐答案

我在bokeh中发现了以下评论,敬请关注:

I found the following comment in bokeh and stay tuned:

好的,这些手绘图例非常笨拙,将在以后的版本中得到改进

目前可以使用:

hold() # stop the curplot() 
# and add the legend just next to the data
x, y = 15.5, 0
for i,area in enumerate(areas):
    rect([x], [y], color=colors[i], width=0.3, height=400)
    text([x], [y], text=area, angle=0, text_font_size="8pt", text_align="center", text_baseline="middle")
    y = y + 100

show()

这篇关于如何在bokeh中显示补丁的图例项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆