Fixed range stops working when a second axis is added

Hi!

I have some scatter chart which uses the range/autorange feature only for one end of the y-axis. The upper end range is set to 100, while to lower end should be dynamically/auto-ranged.

Here is the relevant code for the axis:

var layout = {
    // ...
    yaxis: {
        range: [null,100],
        autorange: 'min'
    },
    // ...

This is working fine, if only a single line is shown in a chart. As soon as I add a second line with its own y-axis, the first line seems to have autorange enabled for both ends of the axis, i.e. the range: [null,100] configuration is ignored.

I’ve created a simple demo on CodePen to show the behavior. Initially only a single line is shown and the y-axis ranges up to 100. As soon as you enable the second line and axis by uncommenting line 8, the range for the first y-axis changes unexpectedly.

Is this a bug or do I miss something that needs to be set to keep the desired behavior?

Thx,
martin

BTW, I’m using Plotly.JS version 2.35.2.

I’ve found an existing bug report, which has the same problem in another use-case. Probably same cause.

I’m not sure I understand well but I think this is what you are looking for, just comment out the two autoranges and the anchor: ‘free’ and uncomment your second axis

1 Like

Thanks @Saratoga!

The anchor: 'free' was the problem. Removing this entry solves the problem and the autorange-feature is working as expected. (The two autorange entries were not necessary but didn’t harm.)

Not sure why I had the anchor: 'free' in the example. It was probably left over from other experiments.

Anyway, could you please explain the anchor property to me and why this effects the autorange? The documentation isn’t of much help. It only references the position property.

Many thanks,
martin