有没有办法在matplotlib中更改坐标轴的颜色(不是嘀嗒声)?我一直在浏览Axes,Axis和Artist的文档,但没有运气; matplotlib画廊也没有提示。 有什么想法?Matplotlib:更改轴的颜色
33
A
回答
61
当使用数字,你可以很容易地改变与脊柱颜色:
ax.spines['bottom'].set_color('#dddddd')
ax.spines['top'].set_color('#dddddd')
ax.spines['right'].set_color('red')
ax.spines['left'].set_color('red')
使用以下方法来改变只蜱:
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')
16
7
您可以通过调整默认的控制设定做。
import matplotlib
from matplotlib import pyplot as plt
matplotlib.rc('axes',edgecolor='r')
plt.plot([0, 1], [0, 1])
plt.savefig('test.png')
+0
Matplotlib还有一个[上下文管理器](http://matplotlib.org/users/style_sheets.html#temporary-styling),它允许临时更改rc参数http://stackoverflow.com/a/41527038/2166823 – 2017-01-07 22:08:33
相关问题
- 1. 如何更改matplotlib 3D图的坐标轴的颜色?
- 2. 更改轴颜色酒窝
- 3. Matplotlib:如何更改轴的颜色和宽度
- 4. 在matplotlib中更改坐标轴的颜色,刻度和标签
- 5. 更改matplotlib中寄生虫轴的颜色
- 6. 更改matplotlib动画中的RGB颜色
- 7. Matplotlib:多种颜色的y轴标签
- 8. 仅更改底部x轴的颜色
- 9. Matplotlib python更改颜色映射中的单一颜色
- 10. Matplotlib填充alpha更改颜色
- 11. matplotlib - 即时更改矩形颜色
- 12. 更改3D图形颜色(matplotlib)
- 13. 使用matplotlib使用多种颜色的颜色轴脊柱
- 14. matplotlib:更改标题和颜色条文本和刻度颜色
- 15. 使用2轴颜色表中matplotlib
- 16. 在Highchart Choropleth中更改颜色轴
- 17. ZEDGraph无法更改轴颜色
- 18. extjs更改图表轴标签颜色
- 19. 更改X轴在matplotlib
- 20. 更改matplotlib轴设置
- 21. matplotlib:更改坐标轴
- 22. matplotlib中的颜色
- 23. 更改颜色
- 24. 更改颜色
- 25. 在matplotlib中改变facecolor的facecolor颜色
- 26. 修改matplotlib中的viridis颜色表(替换一些颜色)
- 27. 如何更改matplotlib图的轴值?
- 28. 如何更改matplotlib中的x轴
- 29. 颜色绘制不同的颜色matplotlib
- 30. 更改NavigationDrawer的颜色点击颜色
优秀的答案,谢谢!给其他人一个注释:''ax.tick_params(axis ='x',colors ='red',which ='both')'' - which =“both”同时改变主要和次要的刻度颜色。 – kinverarity 2015-03-10 10:53:24
'ax.tick_params(axis ='x',colors ='red')'似乎改变了勾号和标签的颜色... – Jonathan 2016-02-16 17:00:30
是否可以使用'ax.yaxis.label.set_color('灰色')'这样一种方式,只有从'y1'到'y2'的嘀嗒声改变他们的颜色,而其他的仍然没有改变? – FaCoffee 2016-03-31 14:27:20