import matplotlib.pyplot as plt#导入matplotlib
x_values = list(range(1, 1001))
y_values = [x * x for x in x_values]#产生两组数据
plt.scatter(x_values, y_values, edgecolor = ‘none’, s = 40, c = y_values,
cmap = plt.cm.Blues)#利用scatter方法进行绘制散点图,传入x,y轴数据,s为字体的宽度,cmap是颜色映射根据c的值进行映射
#设置图表标题,并给坐标轴加上标签
plt.title(“Square Numbers”, fontsize = 24)#设置标题及字体的大小为24
plt.xlabel(“Value”, fontsize = 14)#设置x轴的标题及字体大小为14
plt.ylabel(“Square of Value”, fontsize = 14)#设置y轴的标题及字体大小为14
#设置刻度标记的大小
plt.tick_params(axis = ‘both’, labelsize = 14)#两个坐标轴
plt.axis([0, 1100, 0, 1100000])#坐标轴的范围分别为0-1100,0-1100000.
plt.show()#窗口展示
plt.savefig(‘squaresplot.png’)#保存制图为squaresplot.png