散景:有没有一种方法可以一次设置所有图形的样式?

时间:2019-10-14 16:18:54

标签: python-3.x pandas bokeh

我正在编码20个以上的制表符,以绘制相似的参数,并已分别为每个图形编写样式。有没有一种方法可以一次设置所有图形的样式?

p = figure(tools=TOOLS, x_axis_type='datetime',plot_height=400, plot_width=700,
           outline_line_color = 'gray',
           y_axis_label = 'Volts',
          y_range = DataRange1d()
          )
# Setting the second y axis range name and range
#p.extra_y_ranges = {"foo": Range1d(start=0, end=0.000006)}
p.extra_y_ranges = {"foo": DataRange1d()}

# Adding the second axis to the plot.  
p.add_layout(LinearAxis(y_range_name="foo"), 'right')

a1=p.line(x='Time', y='340', line_color="darkcyan", line_width=1, source=source)
a11 = p.line(x='Time',y='StdDev', line_color = 'red', line_width=1, y_range_name="foo", source=source)
p.y_range.renderers=[a1]
p.extra_y_ranges['foo'].renderers = [a11]

tooltips=[( "Time", "@Time{%H:%M:%S}"),
        ("Y-value", "$y")]
formatt ={'Time':'datetime'}
p.add_tools(HoverTool(tooltips=tooltips, formatters=formatt, mode = 'mouse'))
p.title.text = "Plot Title "
p.title.text_color = "gray"
p.title.text_font = "arial"
p.title.text_font_style = "bold"
p.xgrid[0].grid_line_color=None
p.ygrid[0].grid_line_alpha=0.5
p.xaxis.axis_label = 'TimeStamp'

按照我的方式,我基本上需要为每个选项卡重复以上代码20次以上。

0 个答案:

没有答案