首页 > 解决方案 > Jupyter笔记本中的Seaborn图表忽略了figsize参数

问题描述

出于某种原因,图表大小保持不变,尽管我更改了 figsize 参数。非常感谢您的帮助:)

import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
dt = pd.DataFrame({'col':[26,0,23,7,23,23,22,23,19,22,1,1,11,11,23,14,23,21,11,23,10,11,13,28,18,25,23,28,18,23,18,18,
23,18,23,24,11,28,23,23,23,23,19,23,23,23,23,22,14]})


plt.figure(figsize=(15,6))
sns.displot(dt['col'], kde=True)
plt.show() 

这是我得到的结果

标签: pythonmatplotlibchartsjupyter-notebookseaborn

解决方案


尝试以这种方式重写代码:

g=sns.displot(dt['col'], kde=True)
g.fig.set_size_inches(15,6)

您可以通过了解更多信息


推荐阅读