Python 为什么在试图隐藏图形的某些标签时不执行第二个for循环
我正在尝试使用matplotlib来绘制图形,原始图形的x轴太密集。所以我尝试使用for循环来隐藏一些标签。出于某种原因,只要我在For循环中得到getxticklabels()[::number],python就永远不会执行此操作,即使第一个For循环已经删除。更像是说程序直接跳过循环。下面是代码:Python 为什么在试图隐藏图形的某些标签时不执行第二个for循环,python,python-3.x,matplotlib,Python,Python 3.x,Matplotlib,我正在尝试使用matplotlib来绘制图形,原始图形的x轴太密集。所以我尝试使用for循环来隐藏一些标签。出于某种原因,只要我在For循环中得到getxticklabels()[::number],python就永远不会执行此操作,即使第一个For循环已经删除。更像是说程序直接跳过循环。下面是代码: ax = plt.gca() for label in ax.get_xticklabels(): label.set_visible(False) for label in ax.get
ax = plt.gca()
for label in ax.get_xticklabels():
label.set_visible(False)
for label in ax.get_xticklabels()[::5]:
label.set_visible(True)enter code here
plt.show()