在子图中使用 matplotlib 对象的函数
Function with matplotlib object in subplot
我在 python 中创建饼图,由于自定义,我在函数中编写饼图代码。
现在,我想创建一个子图,其中每个图都是函数的输出。但是,生成的饼图有空格,如何去掉多余的空格?
请参考下面的代码,我是否遗漏了什么?
a= pd.DataFrame([1,2,3])
def test(x):
x.plot.pie(y=0);
fig= plt.figure(); # create a figure object
fig.add_subplot(1, 2, 1); # create an axes object in the figure
test(a)
fig.add_subplot(1, 2, 2) ; # create an axes object in the figure
test(a)
如何将地块放在子地块的正确位置?
绘图时指定坐标轴:
fig, ax = plt.subplots(1, 2)
def test(x, ax):
x.plot.pie(y=0, ax=ax)
test(a, ax[0])
test(a, ax[1])
我在 python 中创建饼图,由于自定义,我在函数中编写饼图代码。 现在,我想创建一个子图,其中每个图都是函数的输出。但是,生成的饼图有空格,如何去掉多余的空格? 请参考下面的代码,我是否遗漏了什么?
a= pd.DataFrame([1,2,3])
def test(x):
x.plot.pie(y=0);
fig= plt.figure(); # create a figure object
fig.add_subplot(1, 2, 1); # create an axes object in the figure
test(a)
fig.add_subplot(1, 2, 2) ; # create an axes object in the figure
test(a)
如何将地块放在子地块的正确位置?
绘图时指定坐标轴:
fig, ax = plt.subplots(1, 2)
def test(x, ax):
x.plot.pie(y=0, ax=ax)
test(a, ax[0])
test(a, ax[1])