How do I make two y-axes associated with a single x-axis? In the image we see that each y-axis has its own x-axis. I already used anchor = ‘x’ in the yaxis2 layout, but nothing has changed.
I’ve seen this example and used the same settings but it did not work. Each y-axis has a distinct x-axis. What can it be? I’ve already put the property anchor: ‘x’ (layout.yaxis2), but it did not solve the problem.
Hello @empet Thank your help. I inserted xaxis: ‘x1’ in my dataY2, but didn’t work
Look at this example that a guy created, because of my post in StackOverflow
Please, use the following traces in that code:
var x = [0.0, 30.0, 45.0, 60.0, 90.0, 120.0, 135.0, 150.0, 180.0];
var y1 = [1.608, 1.3936, 0.9648, 0.60032, 0.08576, -0.71824, -1.1685, -1.5544, -2.0582];
var y2 = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0];
I experimented with both data sets an it works fine:
Perhaps you consider that the second plot is wrong. It’s not the case. The two yaxes have independent ranges and 0 on yaxis1 does not coincide with 0 on yaxis2.
If I change the y2 values to 1.0, instead of 0, I get the following plot:
So I do not know if I can explain correctly what I need. I just did not want the two ‘xaxis’ to appear. So I wanted to know how to “force” the two axes and coincide in the 0. It’s possible?
It worked that way … but the problem is to set the same ‘range’ for both axes y. It often happens that the scale is quite different and the chart is “compressed”. You see? Is there another way? That ‘anchor: x’ is for what?
There is no method, because the two overlaying y-axes are meant with distinct ranges. The xaxis is common, in the sense that it has the same range for both systems of axes: xaxis, yaxis1, respectively xaxis, yaxis2.
setting
zeroline=False
in both yaxis iand yaxis2, the xaxis line is not displayed.
I also got similar issues, here i have 3 different y-axis but 1 x-axis. is there anyway to achieve all y-axis in same zero position but each y-axis need to act independently. More over it should also work for -ve values.