day1/cheatsheet2.tex
changeset 309 0b1f2c378d84
parent 300 f87f2a310abe
child 311 5303c34a3180
equal deleted inserted replaced
306:57291186d598 309:0b1f2c378d84
    23 \vspace{-1in}
    23 \vspace{-1in}
    24 \begin{center}
    24 \begin{center}
    25 \LARGE{Plotting Points}\\
    25 \LARGE{Plotting Points}\\
    26 \large{FOSSEE}
    26 \large{FOSSEE}
    27 \end{center}
    27 \end{center}
    28 \section{Plotting from Data files}
    28 
    29 \begin{verbatim}
       
    30 l = [] #Empty List
       
    31 t = []
       
    32 for line in open('pendulum.txt'): # Opening & Reading files
       
    33     points = line.split() # Splitting a string
       
    34     l.append(float(points[0])) # Appending to a list
       
    35     t.append(float(points[1]))
       
    36 tsq = []
       
    37 for time in t:  #Iterating through lists
       
    38     tsq.append(t*t)
       
    39 plot(l, tsq, '.') # Plotting points
       
    40 \end{verbatim}
       
    41 \section{Plotting Points with Lists}
    29 \section{Plotting Points with Lists}
    42 
    30 
    43 \begin{lstlisting}
    31 \begin{lstlisting}
    44 In [1]: x = [0, 1, 2, 3]
    32 In [1]: x = [0, 1, 2, 3]
    45 In [2]: y = [7, 11, 15, 19]
    33 In [2]: y = [7, 11, 15, 19]