How do you change the size of figures drawn with matplotlib?

后端 未结 19 3023
忘掉有多难
忘掉有多难 2020-11-21 06:01

How do you change the size of figure drawn with matplotlib?

19条回答
  •  孤独总比滥情好
    2020-11-21 06:34

    In case you're looking for a way to change the figure size in Pandas, you could do e.g.:

    df['some_column'].plot(figsize=(10, 5))
    

    where df is a Pandas dataframe. Or, to use existing figure or axes

    fig, ax = plt.subplots(figsize=(10,5))
    df['some_column'].plot(ax=ax)
    

    If you want to change the default settings, you could do the following:

    import matplotlib
    
    matplotlib.rc('figure', figsize=(10, 5))
    

提交回复
热议问题