Skip to content
Advertisement

Wrong column data in figure in Python

I am trying to plot multiple graphs in one figure using subplots. It looks the way I want but the data on x-axis is wrong. Instead of taking the values of ‘Time’ it is taking the number of indices of the csv file imported using pandas. The time is from 0 to 7 milliseconds only. csv is imported as 200000 rows and 5 columns which includes a column for index numbers and 4 columns which I want to use to plot. I have attached my code. could someone help me figure it out?

JavaScript

Advertisement

Answer

You need to specify the same x-axis for each of the datasets:

JavaScript

Giving you:

Matplot lib output

If you also use skiprows=(1, 2), the header columns can also be used.


This could be fully generalised to allow different numbers of CSV files to be passed:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement