我想对数据列进行一些总结可视化+统计。我想将两个或多个子图与描述性表结合起来,并将图形保存在本地。但是,保存绘图时,表格的一部分会被裁剪。
当我执行以下操作时
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
column=np.random.normal(size=10000)
df=pd.DataFrame(column, columns=["Price"])
summary = (
df.describe()
.append((df.isnull().sum()/len(df)*100)
.rename('nans %'))
.iloc[:,0].to_frame()
)
fig, (ax_distplot) = plt.subplots(1, 1, figsize=(25, 12))
#Distplot with summarizing table
sns.distplot(df.loc[:,"Price"], hist=True, bins=30, kde=False, ax=ax_distplot)
ax_distplot.set(ylabel='Count')
tab = ax_distplot.table(cellText=np.around(summary.values, decimals=2),
rowLabels=summary.index,
colLabels=summary.columns, loc="right",
bbox=[1.15, .2, 0.25, 0.8])
使用以下命令在本地保存时
plt.savefig("Price.pdf", bbox_inches="tight")
我努力了
plt.subplots_adjust(right=0.85)
没有任何运气。

