PyPlot:隐藏轴但保留轴标签

时间:2021-03-07 20:38:10

标签: matplotlib subplot

我有以下代码:

import matplotlib.pyplot as plt

fig, axs = plt.subplots(1, 4)
for n, ax in enumerate(axs):
    ax.plot([1, 2], [1, 2])
    ax.set_xticks([])
    ax.set_yticks([])
    ax.set_xlabel(n)
plt.show()

...显示这个:

我想要的是隐藏黑框但保留标签。我试过添加 ax.set_axis_off() 但这也会删除标签:

我该怎么做?

1 个答案:

答案 0 :(得分:1)

只需将刺的颜色更改为无:

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

enter image description here

相关问题