I would like to plot pandas dataframes as subplots.
I read this post: How can I plot separate Pandas DataFrames as subplots?
Here is my minimum example where, like the accepted answer in the post, I used the ax
keyword:
import pandas as pd
from matplotlib.pyplot import plot, show, subplots
import numpy as np
# Definition of the dataframe
df = pd.DataFrame({'Pressure': {0: 1, 1: 2, 2: 4}, 'Volume': {0: 2, 1: 4, 2: 8}, 'Temperature': {0: 3, 1: 6, 2: 12}})
# Plot
fig,axes = subplots(2,1)
df.plot(x='Temperature', y=['Volume'], marker = 'o',ax=axes[0,0])
df.plot(x='Temperature', y=['Pressure'], marker = 'o',ax=axes[1,0])
show()
Unfortunately, there is a problem with the indices:
df.plot(x='Temperature', y=['Volume'], marker = 'o',ax=axes[0,0])
IndexError: too many indices for array: array is 1-dimensional, but 2 were indexed
Please, could you help me ?