代码拉取完成,页面将自动刷新
import matplotlib.pyplot as plt
from matplotlib.font_manager import FontProperties
font_set = FontProperties(fname=r"c:\windows\fonts\simsun.ttc", size=12)
x_values = list(range(1,1001))
y_values = [x**2 for x in x_values]
#随颜色渐变,cmap
plt.scatter(x_values,y_values,c=y_values,cmap=plt.cm.Blues,edgecolor='none',s=40)
plt.axis([0,1100,0,1100000])
#设置图表标题,并给坐标轴加上标签
plt.title("平方图标",fontsize=24,fontproperties=font_set)
plt.xlabel("数字",fontsize=14,fontproperties=font_set)
plt.ylabel("数字的平方值",fontsize=14,fontproperties=font_set)
#plt.show()
#图标自动保存,第二个参数表示裁剪空白部分
plt.savefig('squares.png',bbox_inches='tight')
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。