0

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.

1 Answer 1

1

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. 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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.