一、绘制三点图

 1 """
 2 三月份最高气温
 3 a = 
 4 [12,15,18,6,7,5,6,8,9,10,15,10,4,5,11,10,5,6,12,15,10,5,14,10,10,12,16,5,3,5,5,5,6]
 5 """
 6 
 7 
 8 from matplotlib import pyplot as plt
 9 from matplotlib import font_manager
10 
11 y = [12,15,18,6,7,5,6,8,9,10,15,10,4,5,11,10,5,6,12,15,10,5,14,10,10,12,16,5,3,5,6]
12 
13 x = range(1,32)
14 
15 #设置图像大小
16 plt.figure(figsize=(20,8),dpi = 80)
17 
18 plt.scatter(x,y,label='3月份')
19 
20 
21 #定义字体
22 my_font = font_manager.FontProperties(fname='C:\Windows\Fonts\FZSTK.TTF')
23 #x轴刻度列表
24 xticks_label = ['3月{}日'.format(i) for i in x]
25 
26 #将设置的格式写入x轴
27 plt.xticks(x[::3],xticks_label[::3],fontproperties = my_font,rotation = 45)
28 
29 #设置x轴y轴标题
30 plt.xlabel('日期',fontproperties = my_font)
31 plt.ylabel('温度',fontproperties = my_font)
32 
33 #图例
34 plt.legend(prop=my_font)
35 plt.show()
View Code

相关文章:

  • 2021-11-05
  • 2021-04-03
  • 2021-09-16
  • 2022-01-04
  • 2021-05-18
猜你喜欢
  • 2021-06-22
  • 2021-11-20
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案