0

I am trying to plot the data from the csv file which has data of the following format.

time,odometry_right,odometry_left
1689366898638600587,0.31946682929992676,0.30494561791419983
1689366898688261032,0.28318527340888977,0.3129942715167999
1689366898736572980,0.25154152512550354,0.2811346650123596
1689366898787568807,0.2215549796819687,0.2806363105773926
1689366898836700439,0.23310235142707825,0.27680903673171997
1689366898887266635,0.28109779953956604,0.2958924174308777
1689366898936510562,0.26649942994117737,0.2813049554824829
1689366898987910985,0.2807117998600006,0.29548609256744385
1689366899036507368,0.2811105251312256,0.2811105251312256
1689366899087007522,0.2713738679885864,0.2856566905975342
1689366899136547327,0.2971850037574768,0.28232577443122864
1689366899187739372,0.2812372148036957,0.2812372148036957
1689366899236824035,0.2808254063129425,0.2808254063129425
1689366899286765813,0.2662796974182129,0.28107303380966187
1689366899337327003,0.25154393911361694,0.2663406431674957
1689366899390486478,0.2782253324985504,0.2928687632083893
1689366899437126636,0.2955184578895569,0.26596659421920776
1689366899487092256,0.27621591091156006,0.27621591091156006
1689366899536738872,0.28127074241638184,0.28127074241638184
1689366899587316513,0.24402768909931183,0.24402768909931183
1689366899636921882,0.2071893811225891,0.2515871226787567
1689366899686983346,0.2334650754928589,0.27723976969718933
1689366899736708879,0.25203293561935425,0.25203293561935425
1689366899788047075,0.26180514693260193,0.27634987235069275
1689366899838969707,0.24025367200374603,0.25526952743530273
1689366899887119293,0.23676078021526337,0.26635587215423584
1689366899937592983,0.2812446057796478,0.2664422392845154
1689366899987620115,0.266294926404953,0.25150078535079956
1689366900039707660,0.23341350257396698,0.23341350257396698
1689366900087186336,0.20715580880641937,0.20715580880641937
1689366900137516975,0.20662929117679596,0.1918700635433197
1689366900186663150,0.20016370713710785,0.18586629629135132
1689366900236943721,0.1777782291173935,0.19259308278560638
1689366900286716461,0.1753300130367279,0.1753300130367279
1689366900338431835,0.19237180054187775,0.19237180054187775
1689366900386737108,0.20711779594421387,0.19232365489006042
1689366900436511039,0.20705315470695496,0.20705315470695496

This is my code to plot the data:

right_vel = []
left_vel = []
time = []
 
with open('/home/autosys5/data.csv','r') as csvfile:
    lines = csv.reader(csvfile, delimiter=',')
    next(lines)
    for row in lines:
        time.append(row[0])
        right_vel.append(row[1])
        left_vel.append(row[2])
plt.plot(time,right_vel, label='Right Wheel Speed')
plt.plot(time,left_vel, label='Left Wheel Speed')

plt.xlabel('Time')
plt.ylabel('Speed')
plt.title('Wheel Speeds')
plt.legend()
plt.show()

I got the output as the following: Plot

However, I want an output like the following:

Similar to any line

Could anyone please help me with this?

jared
  • 4,165
  • 1
  • 8
  • 31
icecream
  • 1
  • 1
  • 1
    Your values are strings, not numbers – Trenton McKinney Jul 17 '23 at 20:05
  • `import pandas as pd`, `df = pd.read_csv('/home/autosys5/data.csv')`, `ax = df.plot(x='time', xlabel='Time', ylabel='Speed', title='Wheel Speeds')`. – Trenton McKinney Jul 17 '23 at 20:07
  • Thank you so much for the response. It worked. But is there anyway to get rid of sharp plot and get a smooth curve like the image shown above. – icecream Jul 17 '23 at 20:59
  • [How to smooth a curve for a dataset](https://stackoverflow.com/q/20618804/7758804), https://stackoverflow.com/q/46633544/7758804, https://stackoverflow.com/q/28536191/7758804 – Trenton McKinney Jul 17 '23 at 22:46

0 Answers0