我试图绘制3个子图,其中散点图位于轴[0,0],水平条形图位于轴[0,1],条形图位于轴[1,0]。绘图工作正常,除非我尝试让它们共享轴。下面是我的代码和输出图片:
import matplotlib.pyplot as plt
import pandas as pd
fig, axes = plt.subplots(2,2,figsize=(10,10))
df.plot(x=['LCScore'],
y=['Retail Price (Value)'],
s=bike_df['BV Total']/100,
kind="scatter",
ax=axes[0,0],
alpha=0.5)
df.groupby('Retail Price (Value)')['BV Total'].sum().plot(y='BV Total',
kind="barh",
ax=axes[0,1],
yticks=(80,100,120,140,160,180,200))
df.groupby('LCScore')['BV Total'].sum().plot(y='BV Total',
kind="bar",
ax=axes[1,0])
plt.sca(axes[0,0])
plt.xticks((1,2,3,4),('i','i','c','m'))
plt.sca(axes[1,0])
plt.xticks((1,2,3,4),('i','i','c','m'))
plt.show()
fig.savefig('foo.pdf')
plt.close()
当我将xticks分配给axis [1,0]子图时,这似乎正在发生。