可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
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 anchor
attribute 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 anchor
is 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 false
is 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.