Reputation: 125
I'm currently trying to create an animation in Plotly using Numpy Arrays. The creation of the individual plots works nicely, however when I try to add the individual plots as frames for the animation, the ranging (both autorange and the given limits) are completely ignored. Here's the code:
def animationTest(fields):
fig = go.Figure(
data=[
go.Scatter3d()
],
layout=go.Layout(
xaxis=dict(
range=[-1.,1.],
autorange=False
),
yaxis=dict(
range=[-1.,1.],
autorange=False
),
updatemenus=[
dict(
type='buttons',
buttons=[
dict(
label='Play',
method='animate',
args=[None]
)
]
)
]
),
frames=[
go.Frame(
data=[
go.Scatter3d(
x=it.x,
y=it.y,
z=it.z,
line=dict(color='red',width=2)
)
],
layout=go.Layout(
xaxis=dict(
range=[-1.,1.],
autorange=False
),
yaxis=dict(
range=[-1.,1.],
autorange=False
)
)
)
for it in its]
)
fig.show()
In this case, its
is a list of objects where each object it
has a numpy array of 501 numeric values for each attribute x,y,z
, respectively.
Can anyone figure out why the autorange given in the go.Layout() object is ignored? Thank you very much.
Upvotes: 0
Views: 332
Reputation: 125
I have since figured out the problem - the above given code:
go.Layout(
xaxis=dict(range=[-1.,1.])
)
is the syntax for 2D plots. To adjust the axis limits for 3D plots, use:
go.layout(
scene=dict(
xaxis=dict(range=[-1,1])
)
)
instead, and it should work.
Upvotes: 1