【问题标题】:How do I increase the size of the plot in Jupyter notebook?如何在 Jupyter notebook 中增加绘图的大小?
【发布时间】:2017-03-11 11:01:16
【问题描述】:

我正在尝试在 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')

【问题讨论】:

    标签: visualization data-visualization seaborn


    【解决方案1】:

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

    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")
    

    【讨论】:

    • 这会影响当前单元格还是所有后续单元格?
    【解决方案2】:

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

    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")
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-04-06
      • 1970-01-01
      • 2016-10-10
      • 1970-01-01
      • 2020-06-11
      • 2018-09-06
      • 1970-01-01
      • 2018-12-29
      相关资源
      最近更新 更多