sizeref
中属性plotly.graph_objs._cone.py
的文档字符串说:
Adjusts the cone size scaling. The size of the cones is
determined by their u/v/w norm multiplied a factor and
`sizeref`. This factor (computed internally) corresponds to the
minimum "time" to travel across two successive x/y/z positions
at the average velocity of those two successive positions. All
cones in a given trace use the same factor. With `sizemode` set
to "scaled", `sizeref` is unitless, its default value is 0.5
With `sizemode` set to "absolute", `sizeref` has the same units
as the u/v/w vector field, its the default value is half the
sample's maximum vector norm.
The 'sizeref' property is a number and may be specified as:
- An int or float in the interval [0, inf]
Returns
-------
int|float
在哪里计算出这个神秘的因素,而对于我来说,我找不到在哪里真正计算出它。由于我不了解这个奇怪的因素是如何计算的,因此我在动画中得到了非常奇怪的行为,如下所示:
import numpy as np
import plotly.graph_objs as go
import plotly.offline as pl
###np.around used because plotly.js doesn't like full precision float64s
t = np.linspace(0,2*np.pi,100)
x = np.around(np.vstack((np.cos(t), np.cos(t+np.pi))),decimals=6)
y = np.around(np.vstack((np.sin(t), np.sin(t+np.pi))),decimals=6)
z = np.around(np.vstack((np.ones(len(t)),np.ones(len(t)))),decimals=6)
v = np.around(np.vstack((np.cos(t), np.cos(t+np.pi))),decimals=6)
u = np.around(-np.vstack((np.sin(t), np.sin(t+np.pi))),decimals=6)
w = np.around(np.vstack((np.zeros(len(t)),np.ones(len(t)))),decimals=6)
fig3=go.Figure([dict(anchor="cm",showscale=False,sizemode="scaled",type="cone",x=x[:,0],y=y[:,0]
,z=z[:,0]
,u=u[:,0],v=v[:,0]
,w=w[:,0])],layout=go.Layout(
scene=dict(aspectratio=dict(x=1,y=1,z=0.25),
xaxis=dict(range=[-2,2], tickmode="linear"),
yaxis=dict(range=[-2,2], tickmode="linear"),
zaxis=dict(range=[0,5]))))
fig3.frames= [go.Frame(data=[dict(type="cone",x=x[:,i],y=y[:,i],z=z[:,i],u=u[:,i],v=v[:,i],w=w[:,i])],
layout=go.Layout(annotations=[dict(text="frame {}".format(i))]))for i in np.array(range(len(t)))]
pl.plot(fig3, animation_opts="{frame: {duration: 1}}")
请注意,由于正式版本尚不支持animation_opts(my repo),因此您必须先从see the issue I raised here移除animation_opts
kwarg或使用plotly。
该因子在哪里计算?我已经搜索过代码,但一无所获。 预先感谢!
P.S是的,我提供了很多无关的信息。我还没有看到在plotly中制作3D圆锥动画的示例,所以我想提供一个例子,我在plotly.py中的动画界面上工作,这肯定对某人有用!
编辑:请参见此issue on github