Position new axes programatically.
I would like to request this feature. When creating multiple y axes, have them position automatically, in order to not overlay. In order to do so, you'd have to use the position attribute, with a specified amount.
When adding a new axes, instead of having it on top of the initial one, have it further away from the chart than the first axis. The following link shows exactly how I'd like it to look like, except done automatically, without having to specify numbers for the position attribute:
https://plotly.com/python/multiple-axes/#multiple-axes
My use case is that I have to generate multiple axes without prior knowledge of the amount of axes generated.
@ndrezn Let's discuss implementation possibilities in this issue as they relate to our potential sponsorship opportunity.
The new thing here that we don't have with existing automargin capabilities is that simply using the existing "paper" position for each axis and adjusting the margins to make room isn't enough: that approach can only move items away from the edge, it can't move paper-positioned items away from each other.
From the user's standpoint, I'd think that it should be enough to set:
// the main y axis on the bottom subplot
yaxis: {automargin: true, domain: [0, 0.4]}
// free y axis on top of the first, defaults to left side position 0 - but because this has automargin it gets moved outward
// to stay away from yaxis, and the margin expands to fit them both
yaxis2: {anchor: 'free', overlaying: 'y', automargin: true}
// another free y axis. because 3 > 2, this one moves out beyond yaxis2
// do we need to allow users to control this order, or is it OK if numeric order determines this?
yaxis3: {anchor: 'free', overlaying: 'y', automargin: true}
// main right-side y axis
yaxis4: {side: 'right', overlaying: 'y', automargin: true}
// second right-side y axis - because it's overlaying y and side: right it detects y4 as its "reference" and
// (should?) default to the position of y4 (which is 1 unless xaxis defines a smaller domain)
// and then it moves outward from there
yaxis5: {side: 'right', anchor: 'free', overlaying: 'y', automargin: true}
// main top-subplot y axis
yaxis6: {domain: [0.6, 1], automargin: true}
// any other axes on the top subplot avoid only the other top subplot axes, and do not affect bottom subplot axes
yaxis7: {anchor: 'free', overlaying: 'y6', automargin: true}
In order to support this, and to make it easier to manually position this kind of axis in a way that's independent of layout.width and layout.height, I propose we add yaxis.xshift and xaxis.yshift, as a number of pixels to move an axis - only applicable to anchor: 'free' axes. If axis.automargin=false the shift will default to 0 but can be set manually. But if axis.automargin=true we will BOTH adjust the shift to avoid overlapping earlier axes AND adjust the margin to fit.
Do we need an adjustable padding between axes? I suppose to start we can just pick a nice default like 3 or 5 px, then later if we see the need make that adjustable.
One situation I do NOT think this feature should address, at least for now, is axes drawn between subplots - y axes between side-by-side subplots or x axes between stacked subplots. I suppose if you have two y axes on the left side of a right-side subplot, by using automargin: true they will avoid overlapping each other, but this won't create any more space between the subplots than was already provided by the x axis domains. That would be a nice feature to design, at least for a single axis between subplots, but it's out of scope here.
I think we can use the same ideas for layout.title: add layout.title.xshift and layout.title.yshift attributes, giving number of pixels to move the title relative to where it would otherwise have been; and layout.title.automargin to cause the top margin, and layout.title.yshift in case there's a top-side y axis, to increase if necessary to avoid overlaps.
Hi - we are trying to tidy up the stale issues and PRs in Plotly's public repositories so that we can focus on things that are still important to our community. Since this one has been sitting for several years, I'm going to close it; if it is still a concern, please add a comment letting us know what recent version of our software you've checked it with so that I can reopen it and add it to our backlog. Thanks for your help - @gvwilson