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.
# 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). Now I want, that this range never changes. Just wondering, why they are not providing this as a full example.