简体   繁体   English

在 Matplotlib 中隐藏轴值

[英]Hiding axes values in Matplotlib

I want to hide the x,y axes values as highlighted in the figure.我想隐藏图中突出显示的x,y轴值。 Is it possible to do it?有可能做到吗? I also attach the expected representation.我还附上了预期的代表。

 import numpy as np import matplotlib.pyplot as plt fig = plt.figure() ax = fig.add_subplot(1, 1, 1) n=3 X = np.arange(n) Y = -X x_sorted = np.sort(X) y_sorted = np.sort(Y) ax.set_xticks(x_sorted) ax.set_yticks(y_sorted) ax.set_xlim(x_sorted[0], x_sorted[-1]) ax.set_ylim(y_sorted[0], y_sorted[-1]) ax.grid() ax.set_aspect('equal', 'box') plt.show()

在此处输入图像描述

The expected representation is预期的表示是

在此处输入图像描述

You need to empty x and y tick labels from ax variable:您需要从ax变量中清空xy刻度标签:

 ax.set_yticklabels([]) ax.set_xticklabels([])

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM