我有两张图表。当我放大顶部或底部图表时,x轴都会更新并显示相同的日期范围,这非常好。问题是两个图表上的y轴完全不同,所以当我放大顶部图表时,x&;y轴的刻度相应。在底部图表上,虽然x轴会相应缩放,但y轴不会。我不能使用y_范围=fig.y_范围,因为y范围非常不同
当两个图表的y轴范围不同时,放大顶部图表时,底部图表的y轴是否会相应缩放
更新-我所指的相应更新
假设我的x轴从2020年1月1日到2020年12月31日。现在,假设我使用内置工具在顶部图表上放大2020年7月的整个时间,底部图表的x轴将自动进行相应调整,即,现在在两个图表上放大整个7月的x轴。通过使用直线x_range=fig.x_range,这项工作非常出色。两个图表共享相同的x轴
但是它们的y轴不同,所以我不能使用y_范围=图y_范围
所以我想做的是当我放大顶部图表时&;x&;y轴自动重新缩放。我希望底部图表的y轴也能重新缩放(前面提到的x轴会自动执行此操作)
下面是我的代码
cds = ColumnDataSource(data=df)
fig = figure(plot_width=W_PLOT, plot_height=H_PLOT,
tools=TOOLS,
x_axis_type="datetime",
title=name,
toolbar_location='above')
# lets add a moving average
fig.line(x='time_stamp', y='ma_20', source=cds, legend_label='MA 20')
fig_ind = figure(plot_width=W_PLOT, plot_height=H_PLOT_IND,
tools=TOOLS,
x_axis_type="datetime",
x_range=fig.x_range)
fig_ind.line(x='time_stamp', y='ma_100', source=cds, legend_label='MA 100')
show(gridplot([[fig],[fig_ind]]))
以下是如何在公共X范围内使用
CustomJS
回调来实现这一点:相关问题 更多 >
编程相关推荐