散景:编辑绘图内的所有选项
Bokeh: edit all options inside plot
我有一个包含多条线的图表,如下所示:
p=figure()
p.line(x,y)
p.line(x1,y1)
p.line(x2,y2)
有没有一种简单的方法可以让我在事后向所有行添加选项,而不是在每次插入时重复它们?
例如p.lines(line_width = 2, line_alpha=0.2)
谢谢!
你可以设置一个theme:
from bokeh.io import curdoc, show
from bokeh.plotting import figure
from bokeh.themes import Theme
p = figure()
p.line([1,2,3], [4,5,6], color="red")
p.line([1,2,3], [6,2,4], color="blue")
curdoc().theme = Theme(json={
'attrs': {
'Line': { 'line_width': 10, 'line_alpha': 0.2, },
}
})
show(p)
我有一个包含多条线的图表,如下所示:
p=figure()
p.line(x,y)
p.line(x1,y1)
p.line(x2,y2)
有没有一种简单的方法可以让我在事后向所有行添加选项,而不是在每次插入时重复它们?
例如p.lines(line_width = 2, line_alpha=0.2)
谢谢!
你可以设置一个theme:
from bokeh.io import curdoc, show
from bokeh.plotting import figure
from bokeh.themes import Theme
p = figure()
p.line([1,2,3], [4,5,6], color="red")
p.line([1,2,3], [6,2,4], color="blue")
curdoc().theme = Theme(json={
'attrs': {
'Line': { 'line_width': 10, 'line_alpha': 0.2, },
}
})
show(p)