day1/cheatsheet2.tex
changeset 291 ec70a2048871
parent 284 3c191accbb32
child 300 f87f2a310abe
equal deleted inserted replaced
290:10528e3073ef 291:ec70a2048871
     6 \vspace{-1in}
     6 \vspace{-1in}
     7 \begin{center}
     7 \begin{center}
     8 \LARGE{Plotting Data}\\
     8 \LARGE{Plotting Data}\\
     9 \large{FOSSEE}
     9 \large{FOSSEE}
    10 \end{center}
    10 \end{center}
    11 \section{Scripts}
       
    12 IPython History
       
    13 \begin{verbatim}
       
    14 In [1]: %hist
       
    15 In [2]: %hist -n
       
    16 \end{verbatim}
       
    17 
       
    18 Running a Script
       
    19 \begin{verbatim}
       
    20 In [3]:  %run script_name.py
       
    21 \end{verbatim}
       
    22 
       
    23 \section{Plotting from Data files}
    11 \section{Plotting from Data files}
    24 \begin{verbatim}
    12 \begin{verbatim}
    25 In [1]: L = [] #Empty List
    13 l = [] #Empty List
    26 In [2]: T = []
    14 t = []
    27 In [3]: for line in open('pendulum.txt'): # Opening & Reading files
    15 for line in open('pendulum.txt'): # Opening & Reading files
    28   ....:     points = line.split() # Splitting a string
    16     points = line.split() # Splitting a string
    29   ....:     L.append(float(points[0])) # Appending to a list
    17     l.append(float(points[0])) # Appending to a list
    30   ....:     T.append(float(points[1]))
    18     t.append(float(points[1]))
    31 In [4]: TSq = []
    19 tsq = []
    32 In [5]: for t in T:  #Iterating through lists
    20 for time in t:  #Iterating through lists
    33  ....:     TSq.append(t*t)
    21     tsq.append(t*t)
    34 In [6]: plot(L, TSq, '.') # Plotting points
    22 plot(l, tsq, '.') # Plotting points
    35 \end{verbatim}
    23 \end{verbatim}
    36 \end{document}
    24 \end{document}
    37 
    25