How to make several plots on a single page using matplotlib?

前端 未结 5 2022
离开以前
离开以前 2020-11-27 12:27

I have written code that opens 16 figures at once. Currently they all open as separate graphs. I\'d like them to open all on the same page. Not the same graph. I want 16

5条回答
  •  执笔经年
    2020-11-27 12:53

    @doug & FS.'s answer are very good solutions. I want to share the solution for iteration on pandas.dataframe.

    import pandas as pd
    df=pd.DataFrame([[1, 2], [3, 4], [4, 3], [2, 3]])
    fig = plt.figure(figsize=(14,8))
    for i in df.columns:
        ax=plt.subplot(2,1,i+1) 
        df[[i]].plot(ax=ax)
        print(i)
    plt.show()
    

提交回复
热议问题