python - 关闭 matplotlib 中所有绘图的刻度(使用 rc)

标签 python matplotlib plot

有没有办法使用 matplotlibrc 或其他 matplotlib 配置方法来关闭 xticks 和 yticks ?我目前看到的唯一方法是将刻度和刻度标签的大小设置为零。这看起来很奇怪,因为我可以 set_xticks(())

最佳答案

您可以使用tick_params来做到这一点

plt.tick_params(axis='both', which='both') 

这会影响两个轴(其他选项是xy)。它还会影响主要主要刻度和次要刻度(其他选项为主要次要)

这将在外边缘周围留下刻度,但不会在绘图中留下刻度。如果您想删除边缘刻度,您可以添加:

bottom='off'
top='off'
left='off'
right='off'

如果您想删除标签,则需要关闭这些关闭

labelbottom='off'
labeltop='off'
labelleft='off'
labelright='off'

关于python - 关闭 matplotlib 中所有绘图的刻度(使用 rc),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35045087/

相关文章:

python - 将 Excel 文件流保存到 azure blob 存储

python - MatPlotLib、日期时间和类型错误 : ufunc 'isfinite' not supported for the input types…

python - 如何按升序对条形图中的条形进行排序

r - 如何在对数刻度中使用 `polygon()`?

python - 仅在点图中的 x 轴上显示整数

python - 使用 Python 将列表写入 Excel 中的单元格

python - Django的manage.py测试: “database backend does not accept 0 as a value for AutoField” (mysql)

python - 如何显示来自网络的图像?

python - 为什么我在 matplotlib 中得到额外的空图?

Matlab 多堆积图