Python-删除轴刻度标签,保留刻度和轴标签 [英] Python - Remove axis tick labels, keeping ticks and axis label
本文介绍了Python-删除轴刻度标签,保留刻度和轴标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想删除y轴的每个粗线(10、20、30等)中的数值,但要保留粗线标记和轴标签. 到目前为止,我只有:
I would like to remove the numerical values in each thick of my y-axis (10, 20, 30, etc.) but keeping the thick marks and the axis label. So far I just have:
yticks([])
,但它也删除了刻度线.我也尝试过:
but it removes the ticks as well. I also tried:
frame=gca()
frame.axes.get_yaxis().set_visible(False)
但是它同时删除了轴标签和轴刻度.
but it removes both axis label and axis ticks.
推荐答案
您可以将刻度标签设置为空列表:
You can set the tick labels to an empty list:
from matplotlib.pyplot import *
gca().set_xticklabels(['']*10)
plot(range(10))
结果
在打电话给plot
之前,我必须这样做.不确定为什么其他方法不起作用
I had to do that before I called plot
. Not sure why the other way around didn't work
这篇关于Python-删除轴刻度标签,保留刻度和轴标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文