问题
I'm trying to customize some subplots, but I don't understand what the axis 'anchor' attribute means.
Some examples where this attribute is used are here: https://plot.ly/javascript/subplots/ . What does yaxis2: {anchor: 'x2'} mean? What does anchor=false, or anchor=free mean? I haven't been able to find an explanation in the online docs.
回答1:
To answer my own question, I found the documentation on the axis anchorattribute here.
An x axis can be anchored to a y axis, for example xaxis2: {anchor: 'y2'}means that xaxis2 joins yaxis2 at the origin. If anchoris set to free, the position attribute can then be used to move the axis at another position.
I'm not sure whether setting anchor=false is even possible, I saw that used in the make_subplots function of the plotly.py API here, but it may be that falseis just a value used by the python API internally.
回答2:
Although the anchor mechanism is quite simple, seeing a schema from the start would have saved me a lot of time.
So here's a visual explanation of how subplot axes can be handled in 2D. Each pointed arrow represents an "is anchored to" relationship
Sketch based on the official example.
来源:https://stackoverflow.com/questions/37489942/plotly-js-axis-anchor-attribute