Python matplotlib-带饼图的白色脊椎?

Python matplotlib-带饼图的白色脊椎?,python,matplotlib,pie-chart,Python,Matplotlib,Pie Chart,所以我使用gridspec绘制了一系列子图,所有子图都有黑色背景。现在,对于条形图、线条图等,我使用以下代码在图形周围显示白色边框,这使所有图形都显示在它们自己的白色矩形中: ax.spines['bottom'].set_color('w') ax.spines['left'].set_color('w') ax.spines['top'].set_color('w') ax.spines['right'].set_color('w') 然而,对于饼图来说,这是行不通的,我认为这是因为饼图不

所以我使用gridspec绘制了一系列子图,所有子图都有黑色背景。现在,对于条形图、线条图等,我使用以下代码在图形周围显示白色边框,这使所有图形都显示在它们自己的白色矩形中:

ax.spines['bottom'].set_color('w')
ax.spines['left'].set_color('w')
ax.spines['top'].set_color('w')
ax.spines['right'].set_color('w')
然而,对于饼图来说,这是行不通的,我认为这是因为饼图不需要刺。我想知道一种显示包围axis对象的白色矩形的方法

我在想也许第二个轴在同一位置,有一张透明的脸,但有白色的刺?或者我可以在同一个轴上画一个白色的矩形,但是怎么画呢


谢谢你的帮助

通过打开框架,可以在饼图周围显示一个白色框

from matplotlib.pyplot import axes, pie, show, figure, subplot
import matplotlib.gridspec as gridspec

fig = figure(facecolor = 'k')

ax1 = subplot(111, axisbg='k')
ax1.pie([1,2,3,4])
ax1.set_frame_on(True)
ax1.spines['bottom'].set_color('w')
ax1.spines['left'].set_color('w')
ax1.spines['top'].set_color('w')
ax1.spines['right'].set_color('w')
show()