python数据可视化

1.函数功能:展现变量的趋势变化

调用签名:plt.plot(x, y, ls="-", lw=2, label=“plot figure”)

x: x轴上的数值

y: y轴上的数值

ls:折线图的线条风格 "-' ,  "--",   "-.",   ":"

lw:折线图的线条宽度

label:标记图内容的标签文本

Matplotlib 基本用法https://blog.csdn.net/qq_34859482/article/details/80617391

2.matplotlib plt.tick_params参数解析

参数axis的值为'x'、'y'、'both',分别代表设置X轴、Y轴以及同时设置,默认值为'both'。
ax1.tick_params(axis='x',width=2,colors='gold')
ax2.tick_params(axis='y',width=2,colors='gold')
ax3.tick_params(axis='both',width=2,colors='gold')

参数which的值为 'major'、'minor'、'both',分别代表设置主刻度线、副刻度线以及同时设置,默认值为'major'
ax1.tick_params(which='major',width=2,colors='gold')
ax2.tick_params(which='minor',width=2,colors='gold')
ax3.tick_params(which='both',width=2,colors='gold')

参数direction的值为'in'、'out'、'inout',分别代表刻度线显示在绘图区内侧、外侧以及同时显示
ax1.tick_params(direction='in',width=2,length=4,colors='gold')
ax2.tick_params(direction='out',width=2,length=4,colors='gold')
ax3.tick_params(direction='inout',width=2,length=4,colors='gold')

length和width
参数length和width分别用于设置刻度线的长度和宽度
ax2.tick_params(width=4,colors='gold')
ax3.tick_params(length=10,colors='gold')

参数pad用于设置刻度线与标签间的距离
ax2.tick_params(pad=1,colors='gold')
ax3.tick_params(pad=10,colors='gold')

参数color、labelcolor、colors分别用于设置刻度线的颜色、刻度线标签的颜色以及同时设置刻度线及标签颜色
ax1.tick_params(width=4,color='gold')
ax2.tick_params(width=4,labelcolor='gold')
ax3.tick_params(width=4,colors='gold')


参数labelsize用于设置刻度线标签的字体大小
ax1.tick_params(labelsize='medium')
ax2.tick_params(labelsize='large')
ax3.tick_params(labelsize=15)

参数bottom, top, left, right的值为布尔值,分别代表设置绘图区四个边框线上的的刻度线是否显示
ax1.tick_params(bottom=False,top=True,width=4,colors='gold')
ax2.tick_params(left=False,right=True,width=4,colors='gold')
ax3.tick_params(top=True,right=True,width=4,colors='gold')

参数labelbottom, labeltop, labelleft, labelright的值为布尔值,分别代表设置绘图区四个边框线上的刻度线标签是否显示
ax1.tick_params(labelbottom=False,labeltop=True,width=4,colors='gold')
ax2.tick_params(labelleft=False,labelright=True,width=4,colors='gold')
ax3.tick_params(labeltop=True,labelright=True,width=4,colors='gold')

tick_params:https://blog.csdn.net/helunqu2017/article/details/78736554/

matplotlib方法大全:https://blog.csdn.net/weixin_40637396/article/details/80859180?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-3.channel_param&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-3.channel_param

RGB 常用颜色列表:https://blog.csdn.net/daichanglin/article/details/1563299

原文地址:https://www.cnblogs.com/angelliu/p/13752414.html