Home > Software design >  How to add a new subplot to a figure created by pandas?
How to add a new subplot to a figure created by pandas?

Time:10-20

I'm creating a plot from pandas dataframe using pandas.DataFrame.plot(), which creates 3x2 subplots. I want to add a new subplot to the final spot. However, it doesn't appear. What could be the solution?

ax = DF.plot(x = 'time', 
         y = ['A', 'B', 'C', 'D', 'E'], 
         kind = 'line',
         subplots ='True', 
         layout = (3, 2),
         figsize = (12*2/2.54, 8*3/2.54))
DF.plot(x = 'A', 
        y = 'B', 
        kind = 'line',
        ax = ax[2, 1])

CodePudding user response:

Unhide the last subplot using set_visible:

DF.plot(x = 'A', 
        y = 'B', 
        kind = 'line',
        ax = ax[2, 1])
ax[2, 1].set_visible(True)
  • Related