Closed WenyinWei closed 2 years ago
不合适的坐标类型似乎也会产生问题,如果我将 n 的范围 range(-4, 4 +1) 改为 [-4,-3,-2,-1,0,1,2,3,4],也会出现这样的问题
import pyecharts.options as opts
from pyecharts.charts import Bar3D
coilsys, coil = 'HCFs', 'c'
s_ind = -20
m_, n_ = range(-11, 11 +1), [-4,-3,-2,-1,1,2,3,4] # range(-4, 4 +1)
data_ = [[n,m,np.abs(Bcomp_smn[coilsys][coil]['b1_bis'][s_ind,m,n])] for m in m_ for n in n_]
data_max=max([data[2] for data in data_])/3
bar = ( Bar3D() # init_opts=opts.InitOpts(width="1000px", height="500px")
.add(
series_name="",
data=data_,
xaxis3d_opts=opts.Axis3DOpts(type_="category", name='n', data=n_),
yaxis3d_opts=opts.Axis3DOpts(type_="category", name='m', data=m_),
zaxis3d_opts=opts.Axis3DOpts(type_="value"),
grid3d_opts=opts.Grid3DOpts(width=len(n_)*6, height=40, depth=len(m_)*6),
)
.set_global_opts(
visualmap_opts=opts.VisualMapOpts(max_=data_max)
)
)
bar.render_notebook()
这一段代码可以产生这样的图,
但如果我将它打包成函数的话,就会产生下面奇怪的偏移,