Reputation: 74
i have several sensor measurements saved in several csv files. I want to compare the values in one single plot, but i cant make this work. I always end up open every graph into an own plot.
import matplotlib.pyplot as plt
import pandas as pd
daten = pd.read_csv("testX.csv")
datenZwei = pd.read_csv("testY.csv")
datenDrei = pd.read_csv("testZ.csv")
daten.plot(kind='line', x=' X', y=' Y1 (SX (N/m^2))')
datenZwei.plot(kind='line', x=' X', y=' Y1 (SY (N/m^2))')
datenDrei.plot(kind='line', x=' X', y=' Y1 (SZ (N/m^2))')
plt.show()
This is the result, but i want them all to be in one figure, how can i do that? Thank you for you help.
Upvotes: 0
Views: 667
Reputation: 23
You could try creating a figure with an axes object:
fig, ax = plt.subplots()
and then passing that axes object to the "ax" argument of the pandas plot method:
daten.plot(kind='line', x=' X', y=' Y1 (SX (N/m^2))', ax= ax)
datenZwei.plot(kind='line', x=' X', y=' Y1 (SY (N/m^2))', ax= ax)
datenDrei.plot(kind='line', x=' X', y=' Y1 (SZ (N/m^2))', ax= ax)
Upvotes: 1
Reputation: 374
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.plot(x_value,y_value)
ax.plot(x2_value,y2_value)
substitute x and y values with correct entries on you dataframe
Upvotes: 1