pyecharts3的3D散点图的z轴的尺度化为1995到2006
时间: 2024-02-12 07:08:53 浏览: 67
matplotlib在python上绘制3D散点图实例详解
要将pyecharts3的3D散点图的z轴尺度化为1995到2006,你可以使用以下代码:
```python
from pyecharts import options as opts
from pyecharts.charts import Scatter3D
# 定义散点图的数据
data = [
[10, 1995, 100],
[20, 1996, 200],
[30, 1997, 300],
[40, 1998, 400],
[50, 1999, 500],
[60, 2000, 600],
[70, 2001, 700],
[80, 2002, 800],
[90, 2003, 900],
[100, 2004, 1000],
[110, 2005, 1100],
[120, 2006, 1200],
]
# 创建Scatter3D对象
scatter3d = Scatter3D()
# 添加散点图数据
scatter3d.add(
"",
data,
xaxis3d_opts=opts.Axis3DOpts(type_="value"),
yaxis3d_opts=opts.Axis3DOpts(type_="value"),
zaxis3d_opts=opts.Axis3DOpts(type_="value", min_=1995, max_=2006),
# 设置散点图中点的大小和形状
symbol_size=8,
symbol="circle",
)
# 设置散点图的全局配置
scatter3d.set_global_opts(
visualmap_opts=opts.VisualMapOpts(
range_color=["#313695", "#4575b4", "#74add1", "#abd9e9", "#e0f3f8", "#ffffbf", "#fee090", "#fdae61", "#f46d43", "#d73027", "#a50026"]
)
)
# 渲染图表
scatter3d.render()
```
在上面的代码中,我们通过 `zaxis3d_opts` 参数来设置 z 轴的尺度范围为 1995 到 2006。
阅读全文