相关疑难解决方法(0)

优雅地改变matplotlib中的绘图框的颜色

这是这篇文章的一个后续问题,其中讨论了轴,刻度和标签的着色.我希望为此开一个新的,扩展的问题是可以的.

add_subplot使用轴[ax1,ax2] 围绕双图(通孔)更改完整框架(刻度线和轴)的颜色会产生大量代码.此代码段会更改上图的框架颜色:

ax1.spines['bottom'].set_color('green')
ax1.spines['top'].set_color('green')
ax1.spines['left'].set_color('green')
ax1.spines['right'].set_color('green')
for t in ax1.xaxis.get_ticklines(): t.set_color('green')
for t in ax1.yaxis.get_ticklines(): t.set_color('green')
for t in ax2.xaxis.get_ticklines(): t.set_color('green')
for t in ax2.yaxis.get_ticklines(): t.set_color('green')
Run Code Online (Sandbox Code Playgroud)

因此,为了改变两个图的帧颜色,每个两个y轴,我需要16(!)行代码...这是它的样子:

在此输入图像描述

到目前为止我挖出的其他方法:

是否有一种优雅的方式来凝聚上面的块,更多的是"pythonic"?

我在ubuntu下使用python 2.6.5和matplotlib 0.99.1.1.

python colors matplotlib

24
推荐指数
3
解决办法
3万
查看次数

标签 统计

colors ×1

matplotlib ×1

python ×1