首页 > 其他 > 详细

matplotlib 各种图绘制

时间:2020-04-23 23:01:43      阅读:93      评论:0      收藏:0      [点我收藏+]

散点图绘制

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()

 

matplotlib 各种图绘制

原文:https://www.cnblogs.com/wocaonidaye/p/12764015.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!