matplotlib命令与格式:tick_params参数刻度线样式设置

matplotlib命令与格式:tick_params参数刻度线样式设置1 tick params 语法 Axes tick params axis both nbsp kwargs 参数 axis nbsp x y both Axisonwhicht defaultis both reset nbsp boolIf nbsp True setallparame

原文:http://baijiahao.baidu.com/s?id=&wfr=spider&for=pc

1.tick_params语法

Axes.tick_params(axis=’both’, kwargs)

参数:
axis : {‘x’, ‘y’, ‘both’} Axis on which to operate; default is ‘both’.
reset : bool If True, set all parameters to defaults before processing other keyword arguments. Default is False.
which : {‘major’, ‘minor’, ‘both’} Default is ‘major’; apply arguments to which ticks.
direction : {‘in’, ‘out’, ‘inout’} Puts ticks inside the axes, outside the axes, or both.
length : float Tick length in points.
width : float Tick width in points.
color : color Tick color; accepts any mpl color spec.
pad : float Distance in points between tick and label.
labelsize : float or str Tick label font size in points or as a string (e.g., ‘large’).
labelcolor : color Tick label color; mpl color spec.
colors : color Changes the tick color and the label color to the same value: mpl color spec.
zorder : float Tick and label zorder.
bottom, top, left, right : bool or {‘on’, ‘off’} controls whether to draw the respective ticks.
labelbottom, labeltop, labelleft, labelright : bool or {‘on’, ‘off’} controls whether to draw the respective tick labels.
labelrotation : float Tick label rotation
















2.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’)
matplotlib命令与格式:tick_params参数刻度线样式设置
matplotlib命令与格式:tick_params参数刻度线样式设置
参数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’)
matplotlib命令与格式:tick_params参数刻度线样式设置
matplotlib命令与格式:tick_params参数刻度线样式设置
参数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’)
matplotlib命令与格式:tick_params参数刻度线样式设置
matplotlib命令与格式:tick_params参数刻度线样式设置
length和width
参数length和width分别用于设置刻度线的长度和宽度
ax2.tick_params(width=4,colors=’gold’)
ax3.tick_params(length=10,colors=’gold’)
matplotlib命令与格式:tick_params参数刻度线样式设置
matplotlib命令与格式:tick_params参数刻度线样式设置
参数pad用于设置刻度线与标签间的距离
ax2.tick_params(pad=1,colors=’gold’)
ax3.tick_params(pad=10,colors=’gold’)
matplotlib命令与格式:tick_params参数刻度线样式设置
matplotlib命令与格式:tick_params参数刻度线样式设置
参数color、labelcolor、colors分别用于设置刻度线的颜色、刻度线标签的颜色以及同时设置刻度线及标签颜色
ax1.tick_params(width=4,color=’gold’)
ax2.tick_params(width=4,labelcolor=’gold’)
ax3.tick_params(width=4,colors=’gold’)
matplotlib命令与格式:tick_params参数刻度线样式设置
matplotlib命令与格式:tick_params参数刻度线样式设置
参数labelsize用于设置刻度线标签的字体大小
ax1.tick_params(labelsize=’medium’)
ax2.tick_params(labelsize=’large’)
ax3.tick_params(labelsize=15)
matplotlib命令与格式:tick_params参数刻度线样式设置
matplotlib命令与格式:tick_params参数刻度线样式设置
参数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’)
matplotlib命令与格式:tick_params参数刻度线样式设置
matplotlib命令与格式:tick_params参数刻度线样式设置
参数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’)
matplotlib命令与格式:tick_params参数刻度线样式设置
matplotlib命令与格式:tick_params参数刻度线样式设置




















































版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/218005.html原文链接:https://javaforall.net

(0)
上一篇 2026年3月18日 上午8:16
下一篇 2026年3月18日 上午8:16


相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号