filmov
tv
Setting Axis Range for Subplot in Plotly-Python

Показать описание
Below, you can find the text related to the question/problem. In the video, the question will be presented first, followed by the answers. If the video moves too fast, feel free to pause and review the answers. If you need more detailed information, you can find the necessary sources and links at the bottom of this description. I hope this video has been helpful, and even if it doesn't directly solve your problem, it will guide you to the source of the solution. I'd appreciate it if you like the video and subscribe to my channel!Setting Axis Range for Subplot in Plotly-Python
I am trying to manually set the range of one (shared) y-axis in a plotly multi-plot figure, but for some reason, it also affects the range of the other y-axes.
Take a look at this example. I'll start by creating a 3x2 figure, with a shared y-axis per row.
import numpy as np
N = 20
nrows, ncols, ntraces = 3, 2, 3
fig = make_subplots(
rows=nrows, cols=ncols,
shared_xaxes=True, shared_yaxes=True,
)
for r in range(nrows):
scale = 1 / 10 ** r
for c in range(ncols):
for t in range(ntraces):
row=r + 1, col=c + 1,
trace=go.Scatter(y=y, mode="markers+lines", name=f"trace {t}")
)
import numpy as np
N = 20
nrows, ncols, ntraces = 3, 2, 3
fig = make_subplots(
rows=nrows, cols=ncols,
shared_xaxes=True, shared_yaxes=True,
)
for r in range(nrows):
scale = 1 / 10 ** r
for c in range(ncols):
for t in range(ntraces):
row=r + 1, col=c + 1,
trace=go.Scatter(y=y, mode="markers+lines", name=f"trace {t}")
)
This generates the following figure:
Now I want to manually set the range only for the first row, so I do:
This indeed sets the range as required. Problem is, this upsets all other axes as well, changing their range to some automatic value ([-1, 4]):
[-1, 4]
I tried manually setting the range of the other rows using various combinations of range and rangemode='normal', for example:
range
rangemode='normal'
Nothing seems to work...
How do I manually set the y-axis range only for one of the axes?
Tags: python,python-3.x,plotlySource of the question:
Question and source license information: