2018-12-17 matplotlib 常规操作2

2018-12-17  本文已影响0人  心有余悸天
# -*- coding: utf-8 -*-
from  matplotlib import pyplot as plt 
from matplotlib import  font_manager 
x = range(11,31)
y_1 = [1,2,4,5,6,5,4,74,1,2,35,4,1,5,6,5,4,4,4,2]
y_2 = [1,15,6,4,6,9,1,2,4,2,54,2,5,2,51,3,6,3,6,3]
plt.figure(figsize= (20,8), dpi = 80 )
# 划线 label 名字 , 
# color 颜色 
# lineStyle 折线的样式 ,
# linewidth = 5 线的宽度
# alpha = 0.5
plt.plot(x,y_1, 
         label = 'me', 
         color = 'r' , 
         linestyle = '--',
         linewidth = 5)
plt.plot(x,y_2, 
         label = 'classment', 
         color = '#1f92ef', 
         linestyle = ':', 
         linewidth = 5)
_xtick_labels = ["{}age".format(i) for i in x]
plt.xticks(x, _xtick_labels)
# plt.yticks(range(0,9))
# 网格线
plt.grid(alpha= 0.4, linestyle = ':')
# 图例
# loc=0 图例位置 1,2,3,
# 中文的时候添加 prop 的参数
plt.legend(loc=0)
plt.show()
上一篇 下一篇

猜你喜欢

热点阅读