Funny behaviour when overlaying traces in reverse order

I have found a funny behaviour I don’t understand. If three traces are plotted in the order of the Y axes they belong to, everything is fine like in the image:


There is the last GREEN trace on top of other traces, which can be seen at right of the image.
However if the order of the traces is reversed and correspondingly the overlaying settings of the axes in layout, the green (last) trace is not more on top of the others:

The codepen can be viewed here:
https://codepen.io/stibada/pen/gOppEJa?editors=0010

In my application the behaviour should be consistent as the users can define the traces in any order in the axes perspective.
Am I missing something or is that rather a bug?
Thanks for help!

Thanks for writing in. The behavior does look a little odd.

Before investigating further, here you’re expecting the yaxis2 axis to be above yaxis? In other words, have yaxis3 at the bottom, with yaxis2 above it and then yaxis at the very top.

Hi Etienne, thanks for reply. You understood well what I would expect. In the second example the yaxis3 to be at the bottom, yaxis2 in the middle and at the top the yaxis. More general, the last trace added should be at the top. Just a hint that may give you a direction. I discovered this behaviour only if I had 3 or more axes. With 2 axes, everything seems to be OK to me. Thank you very much for help!