MUD
MUD

Reputation: 121

How to plot multiple series of pandas data on the same graph?

I have a data file which contains 100 columns of 100 different series of solar irradiance vs. time. I want to plot all of these series on the same graph with the same time x-axis. Is there a way to do this in pandas without specifying the column names? I have not included headers in the results file. The number of data series will also change so I want the code to be able to cope with varying numbers of data sets.

Shapshot of results file: enter image description here

I have been using matplotlib but I think this would be easier to handle in pandas, however everything I can find online suggests using the column headers.

So far all I have is this:

data = pd.read_csv(outputFile)
data.plot.line(x="Time")

Upvotes: 1

Views: 675

Answers (1)

Michael
Michael

Reputation: 5335

Read the first column as index, then all remaining columns will be plotted.

data = pd.read_csv(outputFile, header=None, index_col=0, sep='\s+')
data.plot.line(xlabel='Time')

Upvotes: 3

Related Questions