Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

plotly.js axis 'anchor' attribute

Tags:

plotly

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.

like image 352
sam81 Avatar asked May 27 '16 18:05

sam81


People also ask

What is anchor in Plotly?

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.

How do you get rid of the grid on Plotly?

How do you remove gridlines in Plotly? Toggling Axis grid lines Axis grid lines can be disabled by setting the showgrid property to False for the x and/or y axis.


2 Answers

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

enter image description here

Sketch based on the official example.

like image 82
Arnaud P Avatar answered Sep 30 '22 19:09

Arnaud P


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.

like image 43
sam81 Avatar answered Sep 30 '22 20:09

sam81