day1/cheatsheet2.tex
changeset 284 3c191accbb32
child 291 ec70a2048871
child 295 39d7c4e14585
equal deleted inserted replaced
283:5d7ca20e955f 284:3c191accbb32
       
     1 \documentclass[12pt]{article}
       
     2 %\title{Plotting Data}
       
     3 %\author{FOSSEE}
       
     4 \begin{document}
       
     5 \date{}
       
     6 \vspace{-1in}
       
     7 \begin{center}
       
     8 \LARGE{Plotting Data}\\
       
     9 \large{FOSSEE}
       
    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}
       
    24 \begin{verbatim}
       
    25 In [1]: L = [] #Empty List
       
    26 In [2]: T = []
       
    27 In [3]: for line in open('pendulum.txt'): # Opening & Reading files
       
    28   ....:     points = line.split() # Splitting a string
       
    29   ....:     L.append(float(points[0])) # Appending to a list
       
    30   ....:     T.append(float(points[1]))
       
    31 In [4]: TSq = []
       
    32 In [5]: for t in T:  #Iterating through lists
       
    33  ....:     TSq.append(t*t)
       
    34 In [6]: plot(L, TSq, '.') # Plotting points
       
    35 \end{verbatim}
       
    36 \end{document}
       
    37