0

Im trying to plot some data from an experiment but the timer starts a bit before the start of my variable. I have tried to create a new list of times starting from 0 but when I do so my loop generates more values for my array then the length of the original array which makes it impossible to plot.

Aplate = np.loadtxt('Plates Angular poston_2.txt')

t1 = []
for i in Aplate:
    t = Aplate[:,0]
      for j in t:
      if j < 27.4150:
         x = j -3.01 
         t1.append(x)
     else:
         break 

y = Aplate[:,1]

plt.plot(t1, y)
plt.show()

1 Answers1

0

If you are simply accounting for a constant delay in the start of data recording, why not just do

plt.plot( t-delay ,y ) 

where delay is 3.01? ( see here: https://stackoverflow.com/a/4918586/4916534 )

Also, if you want the columns to be the same length, why not populate y and t in the same loop? You are currently asking python to give you x values for all times < 27.4150, but to give you y values for all times.

Community
  • 1
  • 1
Andrew C
  • 61
  • 1
  • 4