2018-12-17 matplotlib 常规操作2

# -*- 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()
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容