【发布时间】:2021-06-17 08:22:04
【问题描述】:
这是一个简短的 Python3 脚本,它使用散景 (2.2.1) 绘制一堆正弦波。
import numpy
import bokeh.models
import bokeh.plotting
x = numpy.linspace(0, 4*numpy.pi, 100)
sinx = numpy.sin(x)
bokeh.plotting.output_file("truncatedlegend.html")
plot = bokeh.plotting.figure(toolbar_location="above")
glyphs = [ plot.line(x, (1 + i/20)*sinx, line_width=2) for i in range(41) ]
legend = bokeh.models.Legend(
items=[
("%.2f*sin(x)" % ((1 + i/20)), [ glyphs[i] ]) for i in range(41)
]
)
plot.add_layout(legend, 'right')
bokeh.plotting.show(plot)
图例应该有 40 个条目,但只有 24 个条目的空间,所以其余的都被丢弃了。我尝试改变情节的边缘,
margin = plot.margin
plot.margin = (margin[0], margin[1], margin[2] + 600, margin[3])
它确实增加了可用空间(第二个图(未显示)向下移动)---但图例没有扩展到可用空间。
【问题讨论】: