标签:rand att gen fonts and form int show manager
散点图绘制
from matplotlib import pyplot as plt import random from matplotlib import font_manager myfont = font_manager.FontProperties(fname="C:\Windows\Fonts\simkai.ttf") # x轴显示日期 x_3 = range(1,32) x_10 = range(51,82) # 设置一个0~40随机温度显示在y轴 y_3 = [random.randint(0,40) for i in range(1,32)] y_10 = [random.randint(0,40) for i in range(1,32)] # 设置图形大小 plt.figure(figsize=(20, 8) ,dpi=80)
# 散点图用scatter plt.scatter(x_3,y_3,label= "3月份") plt.scatter(x_10, y_10, label = "10月份") # 调整x的刻度 _x = list(x_3)+list(x_10) _xtick = ["3月{}日".format(i) for i in x_3] _xtick +=["10月{}日".format(i-50) for i in x_10] plt.xticks(_x[::3], _xtick[::3] , rotation= 40, fontproperties= myfont) # 设置标题 plt.xlabel("期日", fontproperties = myfont) plt.ylabel("温度", fontproperties = myfont) plt.title("三月份和十月份温度", fontproperties = myfont) # 设置图形lebel显示位置 plt.legend(loc = 2,prop = myfont) plt.show()
标签:rand att gen fonts and form int show manager
原文地址:https://www.cnblogs.com/wocaonidaye/p/12764015.html