I have a panda time series (x) with time index t and numpy array (y) of same length. i need to create a plot of x,y on y axis and time (t) on x axis.
x.shape (320,)
y.shape (320,1)
i tried converting numpy array but it gives me an error(Data must be 1-dimensional).
pd.Series(y,index=x.index)
Assuming that your x
is a panda series and y
is a numpy array
import matplotlib.pyplot as plt
plt.figure()
plt.plot(x.index.values, y, label="y")
plt.plot(x.index.values, x.value, label="x")
plt.legend()
plt.show()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.