如何增加 Jupyter notebook 中绘图的大小?

How do I increase the size of the plot in Jupyter notebook?

我正在尝试在 python 中使用 Seaborn 绘制直方图。我正在使用 sns.distplot 函数绘制直方图。我想让我的图表更宽一点。我怎么做?我尝试了 python 中的帮助功能,但没有帮助。谢谢

sns.set_style("dark")

ax = sns.distplot(data["Trip_distance"], bins= 50, kde= False, axlabel= "Trip Distance")

ax.set_ylabel('Count')

找到答案了。下面代码的第一行。

sns.set(rc={"figure.figsize": (8, 4)})
sns.set_style("dark")
ax = sns.distplot(data["Trip_distance"], bins= 50, kde= False, axlabel= "Trip Distance")
ax.set_ylabel('Count')
ax.set_title("Histogram of Trip Distance")

另一种方法是在绘制之前创建图形和坐标轴。

import matplotlib.pyplot as plt
import seaborn as sns
fig, ax = plt.subplots(figsize=(8,6))
sns.distplot(data["Trip_distance"], bins= 50, kde= False, axlabel= "Trip Distance", ax= ax)
ax.set_ylabel('Count')
ax.set_title("Histogram of Trip Distance")