✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
⚡️ Concerned about the grid? Kyle Baranko teaches how to predicting peak loads using XGBoost. Register for the August webinar!

Y-Axis Reference Line

I am trying to create a reference line on the y-axis. Currently, I’m using a line shape and annotation. This works fine, except that I want the shape to continually grow on the x-axis as the user zooms in and out. Is there a way to set this so the shape and annotation dynamically grow on the x-line as the user zooms?

TIA!

Chiara

Hmm. I’m not sure I understand what you mean by grow on the x-axis. This may be related to one of our newest feature fixed size shapes added in https://github.com/plotly/plotly.js/pull/2532

Hey, @etienne. Thanks for the reply :slight_smile:

I don’t think that’s what I’m looking for, but maybe I don’t understand all of the benefits of that pull request.

When I say “grow” I mean redraw the line to take up the entire view of the plot.

In the below image, the “Medium Refractive Index” line is a shape and annotation that is dynamically added to the plot based on the dataset being explored. Currently, the high end of the x-range is hard-coded to be 5. So, when you zoom in on the plot, you loose the annotation, and when you zoom out of the plot, the line does not extend all the way to the high end of the x axis.

Does that make more sense now? If it does, is there a way to achieve what I want with the current API?

Thanks!
Chiara

If you want exactly the entire view of the plot, you can try something like:

where the ‘x’ coordinates of the shape are in paper reference frame, so they don’t move as you zoom in.

1 Like

Yes, that’s it exactly. Thank you!

1 Like

Do you know how to make it by python?