有没有办法改变 matplotlib 中 Axis (而不是刻度线)的颜色?我一直在浏览 Axes、Axis 和 Artist 的文档,但没有运气; matplotlib 画廊也没有任何提示。 有什么想法吗?
请您参考如下方法:
使用图形时,您可以通过以下方式轻松更改书脊颜色:
ax.spines['bottom'].set_color('#dddddd')
ax.spines['top'].set_color('#dddddd')
ax.spines['right'].set_color('red')
ax.spines['left'].set_color('red')
使用以下命令仅更改刻度:
which="both"
更改主要和次要刻度线颜色
ax.tick_params(axis='x', colors='red')
ax.tick_params(axis='y', colors='red')
以下内容仅更改标签:
ax.yaxis.label.set_color('red')
ax.xaxis.label.set_color('red')
最后是标题:
ax.title.set_color('red')