Wes
Wes

Reputation: 266

Plot Multiple Data Sets that have same X and different Y

I'm developing a software that get data from Csv file and plot them in the Same chart using same X coordinates but different Y coordinates for each Signal.

The Csv file structured like that:

DateTime;S1;S2;S3
2020-07-15 08:55:25.409877;999.1321411760139;731.5787800868936;934.9127699585481
2020-07-15 08:55:25.416509;937.8423437386526;492.8973514443781;289.0147319623144

Datetime is the header of X coordinates and is the Time

S1,S2,etc.. are the headers of Y coordinates and are Signals Values

I want to read data from csv and plot a chart that has DateTime on X coordinates equals for each Signals, and for each time the chart has S1 Y coordinate for the first Datetime coordinate, S2 for the second Datetime.... and so on.

This is an example of Output: https://drive.google.com/file/d/1AIo1MzNEw_XeJ_PbcZsXSTGvHCYBVTYs/view?usp=sharing

Upvotes: 0

Views: 465

Answers (1)

Gabriel Milan
Gabriel Milan

Reputation: 723

One way you could do that is through Pandas and Matplotlib

import pandas as pd
import matplotlib.pyplot as plt

df = pd.read_csv('your_csv_file.csv', sep=';')

x_col  = 'DateTime'
y_cols = [col for col in df.columns if col != x_col]

plt.plot(df[x_col], df[y_cols])
plt.show()

Upvotes: 1

Related Questions