AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Subplot titles plotly12/5/2023 In the definition of the layout xaxis defines the formatting and styling of the x axis for that figure. In the definition of a trace, xaxis defines which x axis the trace will be bound to. To repeat, these are attributes of each trace and are different from the attributes of the layout dictionary. To change this, each trace has two attributes, yaxis and xaxis that determine which axis or axes that trace is bound to. By default, each trace is bound to the default or initial x and y axes. Traces can be bound to any trace, technically. Īs mentioned above, plotly is liberal with how the axes are arranged and how traces are bound to them. Try zooming or panning the second y axis - the new axis remains unchanged and no trace follows it. You'll notice though, that neither of the traces have been bound to the new axis. So, to appropriately position our axis, we must add it with the following attributes: (yaxis2 = go.YAxis(overlaying= 'y', side= 'right')) If you'd like, try adding a new axis without these attributes set appropriately to get a an intuitive feeling for what they do. For it to be placed on the other side, we must use the attribute side and set it to the opposite of the pre-existing one, which for us, by default is on the left side. Thus, for our new y axis, by default it will literally be placed on top of the pre-existing one, which doesn't work well. The default side for a y axis, is the left, whilst for an x axis, it is the bottom. If it needs to connect to a y axis, overlaying='y' if it needs to connect to an x axis, overlaying='x'. To connect it to a pre-existing axis, pass the kind of axis it needs to connect to. The attribute used for this setting is overlaying. We have to tell it to be sort of 'connect' with the pre-existing yaxis. Like mentioned above, plotly lets axes do what ever you want, essentially, so the default is that an axis is free. In our case, we want the new axis to be overlapping.
0 Comments
Read More
Leave a Reply. |