第1关:Scatter:散点图(一)
编程要求
根据以上介绍,在右侧编辑器补充代码,绘制给定数据的散点图,要求:
-
画布大小初始化为宽 1600 像素,高 1000 像素
-
X 轴数据设置为
x_data
-
添加 Y 轴数据。系列名称设置为空,数据使用
y_data
,标记的大小设置为20,不显示标签 -
X 轴类型设置为数值轴,并显示分割线
-
Y 轴类型设置为数值轴,并显示分割线以及坐标轴刻度
-
不显示提示框
from PreTest import *
from pyecharts import options as opts
from pyecharts.render import make_snapshot
from snapshot_phantomjs import snapshot
from pyecharts.charts import Scatter
data = [
[10.0, 8.04],
[8.0, 6.95],
[13.0, 7.58],
[9.0, 8.81],
[11.0, 8.33],
[14.0, 9.96],
[6.0, 7.24],
[4.0, 4.26],
[12.0, 10.84],
[7.0, 4.82],
[5.0, 5.68],
]
data.sort(key=lambda x: x[0])
x_data = [d[0] for d in data]
y_data = [d[1] for d in data]