我正在努力放大和缩小一个波基烛台图形。放大的时候太过详细了,我希望它在放大的时候停在至少5-7条的某个地方(取决于光标的位置),缩小的时候回到原来的图形(不管光标的位置,回到原来的图形)。你知道吗
我试过玩match_aspect=True
和bm.DataRange1d
,但我还是不明白这些是怎么回事。你知道吗
到目前为止,它放大到毫秒,缩小到很远,而不是根据初始图形的纵横比。你知道吗
import pandas as pd
import bokeh.models as bm
from bokeh.io import show, output_file
from bokeh.plotting import figure
from bokeh.sampledata.stocks import MSFT
df = pd.DataFrame(MSFT)[:51]
inc = df.close > df.open
dec = df.open > df.close
p = figure( tools='xpan, xwheel_zoom', active_scroll='xwheel_zoom',
plot_width=1000, plot_height=500, title = "MSFT", x_range=bm.DataRange1d(bounds='auto'),
active_drag='xpan')
# map dataframe indices to date strings and use as label overrides
p.xaxis.major_label_overrides = {
i: date.strftime('%b %d') for i, date in
p.xaxis.bounds = (0, df.index[-1])
p.segment(df.index, df.high, df.index, df.low, color="black")
p.vbar(df.index[inc], 0.5, df.open[inc], df.close[inc], fill_color="#D5E1DD", line_color="black")
p.vbar(df.index[dec], 0.5, df.open[dec], df.close[dec], fill_color="#F2583E", line_color="black")
show(p)
理想情况下,我希望得到类似于tradingview网站的缩放效果
DataRange1d
范围具有^{相关问题 更多 >
编程相关推荐