【问题标题】:Hiding axes values in Matplotlib在 Matplotlib 中隐藏坐标轴值
【发布时间】:2022-07-04 15:21:20
【问题描述】:

我想隐藏图中突出显示的x,y 轴值。有可能做到吗?我还附上了预期的表示。

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()

预期的表示是

【问题讨论】:

    标签: python numpy matplotlib


    【解决方案1】:

    您需要从ax 变量中清空xy 刻度标签:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-01-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多