简体   繁体   English

Python 散景 plot static 次 y 轴

[英]Python Bokeh plot static secondary y axis

I'm just trying to use the candlestick example and adding a volume bar chart.我只是想使用烛台示例并添加一个成交量条形图。 So far so good.到目前为止,一切都很好。 I want to have a static range on my secondary y axis, so that all zooming only happens on the primary axis.我想在我的辅助 y 轴上有一个 static 范围,以便所有缩放只发生在主轴上。

# Candlestick price chart
inc = df.close >= df.open
dec = df.open > df.close
p = figure(x_axis_type="datetime", y_range=Range1d(start=df["low"].min(), end=df["high"].max()), tools=TOOLS, plot_height=400, plot_width=WIDTH, title = "OHLC")
p.extra_y_ranges = {"vol": Range1d(start=0, end=df["volume"].max()*2)}
p.add_layout(LinearAxis(y_range_name="vol"), 'right')
p.xaxis.major_label_orientation = pi/4
p.grid.grid_line_alpha=0.3
# Volume
p.vbar(x=df.date, top=df.volume, bottom=0, width=CANDLES, fill_color="blue", line_color="blue", alpha=0.1, y_range_name='vol')
# OHLC
p.segment(df.date, df.high, df.date, df.low, color="black")
p.vbar(df.date[inc], CANDLES, df.open[inc], df.close[inc], fill_color="#58b258", line_color="black")
p.vbar(df.date[dec], CANDLES, df.open[dec], df.close[dec], fill_color="#d74c47", line_color="black")

I added the extra_y_range with minimum 0 and maximum double max volume (for better visibility).我添加了最小 0 和最大双倍最大音量的 extra_y_range(为了更好的可见性)。 Now I want, that this range never changes.现在我想要,这个范围永远不会改变。 Just wondering, why they are not providing this as a full example.只是想知道,为什么他们不提供这个作为一个完整的例子。

Now I want, that this range never changes.现在我想要,这个范围永远不会改变。

Currently (as of version 2.0.2), extra axes are always linked together to maintain their original relative scale.目前(从 2.0.2 版开始),额外的轴总是链接在一起以保持它们原来的相对比例。 It's not possible to have a second axis that does not rescale while the other axis changes range.当另一个轴改变范围时,不可能有第二个轴不重新缩放。 AFAIK there is not any issue on GiHub asking for this, so you could open one to propose it as a feature. AFAIK GiHub 上没有任何问题要求此功能,因此您可以打开一个建议将其作为一项功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM