plotting-files.txt
changeset 32 74bf7904691d
parent 27 5712cc7589f9
equal deleted inserted replaced
31:7b685ae49b57 32:74bf7904691d
    18 plot (x, y, 'o')
    18 plot (x, y, 'o')
    19 
    19 
    20 Here, we have our plot! 
    20 Here, we have our plot! 
    21 [We close the plot window. ] 
    21 [We close the plot window. ] 
    22 
    22 
    23 Now, that we know how to plot data from lists, we will look at plotting data from a text file. Essentially, we read the data from the file and fit them into lists again. Then we can easily plot it, as we already did before. 
    23 Now, that we know how to plot data from lists, we will look at plotting data from a text file. Essentially, we read the data from the file and fit them into lists again. Then we can easily plot it, as we  did before. 
    24 
    24 
    25 As an example we will use the data collected from a simple pendulum experiment. 
    25 As an example we will use the data collected from a simple pendulum experiment. 
    26 
    26 
    27 In []: cat pendulum.txt (windows wont work!)
    27 In []: cat pendulum.txt (windows wont work!)
    28 The cat command shows the file content.
    28 The cat command shows the file content.
    57     tsq.append(time*time) 
    57     tsq.append(time*time) 
    58 
    58 
    59 Now lists l(en) and tsq have the required data. We can simply plot them, as we did earlier. 
    59 Now lists l(en) and tsq have the required data. We can simply plot them, as we did earlier. 
    60 plot(l, tsq, 'o')
    60 plot(l, tsq, 'o')
    61 
    61 
    62 So here is the required plot. In this way, you can plot data from files.  Hope this information was helpful. See you. 
    62 So here is the required plot. In this way, you can plot data from files.  Hope this information was helpful. See you in the next tutorial 
    63 
    63 
    64 ******************
    64 ******************
    65 
    65 
    66 For alternate ways of loading data from files go through the tutorial on loadtxt
    66 For alternate ways of loading data from files go through the tutorial on loadtxt
    67 We should have two tutorials here, one should be basic, using for loops and lists
    67 We should have two tutorials here, one should be basic, using for loops and lists