How to Plot csv file

csv file format:
Name Jitter Latency PacketLoss TimeStamp
Joe 34 64 0 1324244672
Joe 54 23 1 1724584472
. . . . .
. . . . .
Mark 76 86 0 122428467
Mark 64 84 0 1824264672
. . . . .
. . . . .
John 74 23 1 1524284472
John 73 86 2 1224584672

my code:
#import libraries
import pandas as pd
import matplotlib.pyplot as plt

read data from csv file

data = pd.read_csv(r’C:\Users\james\Desktop\myfile.csv’,encoding=‘utf-8’).fillna(0)

#plot column “Jitter” of first 10 values
#display first 10 values

#PLot item for line graph of RED color
#Need figure item

#Title of the Graph
ax.set_title(“Plot of Jitter for Joe”)

#X axis label
ax.set_xlabel(“Time Samples”)

#Y axis label

leg = ax.legend()

#display graph

Note: this code is already working, it can already plot the Jitter values. I learned this in online tutorial


  1. how i can insert the “Latency” and “PacketLoss” values to my graph of different color?
  2. How to plot remaining values for different names for Mark and John?
  3. How can I use the actual Timestamp to use as my time reference?

Your help is highly appreciated. I am a novice and just following examples from online tutorials.

To answer your questions:

  1. Use the line

and type “Latency” or “PacketLoss” instead of “Jitter”.
Add another line of


but now instead with the label that you’ve assigned Latency or PacketLoss to.
2. You can filter your DataFrame values by the column Name
3. The ax.plot()-method takes both an x-argument and a y-argument, and you can use the column Timestamp as your x-value.

Thanks Emil, is there a way to automatically read all the values under name (e.g. Joe, Mark, John) that i dont need to do it manually?

Like for this command that i need to specify the range:

Hi Oliver,

I’m sorry for this late reply. If you can still use it, here is what I’d do.

To get an array of the names, you can use the line

names = data['Name'].unique()

(as in here)

Then filter out the part of the data frame with a specific name in the ‘Name’-column and plot for all names with a for-loop. Say, for example, you want to plot timestamp vs. jitter for all names:

for name in names:
    reduced_data = data[data['Name']==name]
    x = reduced_data['Timestamp']
    y = reduced_data['Jitter']
    ax.plot(x,y,label='Jitter for {}'.format(name))

a quite good explanation of how to filter a data frame by the values in a column can be found here.