SlideShare uma empresa Scribd logo
1 de 24
Baixar para ler offline
Barcelona Python Meetup



Plotting data with python and
            pylab
        Giovanni M. Dall'Olio
Problem statement
   Let's say we have a table of data like this:
     name        country     apples      pears
     Giovanni    Italy       31          13
     Mario       Italy       23          33
     Luigi       Italy       0           5
     Margaret    England     22          13
     Albert      Germany     15          6

   How to read it in python?
   How to do some basic plotting?
Alternatives for plotting
          data in python
   Pylab (enthought)→ Matlab/Octave approach
   Enthought → extended version of Pylab (free for 
     academic use)
   rpy/rpy2 → allows to run R commands within 
      python
   Sage → interfaces python with Matlab, R, octave, 
      mathematica, ...
The Pylab system
   pylab is a system of three libraries, which together 
     transform python in a Matlab­like environment
   It is composed by:
          Numpy (arrays, matrices, complex numbers, etc.. in 
            python)
          Scipy (extended scientific/statistics functions)
          Matplotlib (plotting library)
          iPython (extended interactive interpreter)
How to install pylab
   There are many alternatives to install PyLab:
          use the package manager of your linux distro 
          use enthought's distribution (
             http://www.enthought.com/products/epd.php) (free 
             for academic use)
          compile and google for help!
   Numpy and scipy contains some Fortran libraries, 
     therefore easy_install doesn't work well with 
     them
ipython -pylab
   Ipython is an extended version of the standard 
      python interpreter
   It has a modality especially designed for pylab
   The standard python interpreter doesn't support 
     very well plotting (not multi­threading)
   So if you want an interactive interpreter, use 
     ipython with the pylab option:

           $: alias pylab=”ipython -pylab”
           $: pylab

        In [1]:
Why the python interpreter
is not the best for plotting




     Gets blocked when you create a plot
How to read a CSV file with
         python
   To read a file like this in pylab:
      name        country     apples     pears
      Giovanni    Italy       31         13
      Mario       Italy       23         33
      Luigi       Italy       0          5
      Margaret    England     22         13
      Albert      Germany     15         6

   → Use the function 'matplotlib.mlab.csv2rec'
         >>> data = csv2rec('exampledata.txt',
           delimiter='t')
Numpy - record arrays
   csv2rec stores data in a numpy recarray object, where 
      you can access columns and rows easily:
     >>> print data['name']
     ['Giovanni' 'Mario' 'Luigi' 'Margaret'
      'Albert']

     >>> data['apples']
     array([31, 23, 0, 22, 15])

     >>> data[1]
     ('Mario', 'Italy', 23, 33)
Alternative to csv2rec
   numpy.genfromtxt (new in 2009)
   More options than csv2rec, included in numpy
   Tricky default parameters: need to specify dtype=None

      >>> data = numpy.genfromtxt('datafile.txt',
     dtype=None)
      >>> data
      array....
Barchart
>>> data = csv2rec('exampledata.txt', delimiter='t')

>>> bar(arange(len(data)), data['apples'], color='red',
width=0.1, label='apples')

>>> bar(arange(len(data))+0.1, data['pears'],
color='blue', width=0.1, label='pears')

>>> xticks(range(len(data)), data['name'], )

>>> legend()

>>> grid('.')
Barchart
  >>> data = csv2rec('exampledata.txt',
delimiter='t')

>>> figure()
>>> clf()


 Read a CSV file and storing 
  it in a recordarray object


 Use figure() and cls() to 
  reset the graphic device
Barchart
>>> data = csv2rec('exampledata.txt',
delimiter='t')

>>> bar(x=arange(len(data)), y=data['apples'],
color='red', width=0.1, label='apples')

   The bar function creates a 
     barchart
Barchart
>>> data = csv2rec('exampledata.txt',
delimiter='t')

>>> bar(x=arange(len(data)), y=data['apples'],
color='red', width=0.1, label='apples')

>>> bar(arange(len(data))+0.1, data['pears'],
color='blue', width=0.1, label='pears')


   This is the second barchart
Barchart
>>> data = csv2rec('exampledata.txt',
delimiter='t')

>>> bar(x=arange(len(data)), y=data['apples'],
color='red', width=0.1, label='apples')

>>> bar(arange(len(data))+0.1, data['pears'],
color='blue', width=0.1, label='pears')


>>> xticks(range(len(data)), data['name'], )


   Re­defining the labels in the X axis 
     (xticks)
Barchart
>>> data = csv2rec('exampledata.txt',
delimiter='t')

>>> bar(x=arange(len(data)), y=data['apples'],
color='red', width=0.1, label='apples')

>>> bar(arange(len(data))+0.1, data['pears'],
color='blue', width=0.1, label='pears')

>>> xticks(range(len(data)), data['name'], )

>>> legend()
>>> grid('.')
>>> title('apples and pears by person')

   Adding legend, grid, title
Barchart (result)
Pie Chart
>>> pie(data['pears'], labels=data['name'])
>>> pie(data['pears'], labels=['%sn(%s
  pears)' % (i,j) for (i, j) in
  zip(data['name'], data['pears'])] )
Pie chart (result)
A plot chart
>>> x = linspace(1,10, 10)
>>> y = randn(10)
>>> plot(x,y, 'r.', ms=15)
 
An histogram
>>> x = randn(1000)
>>> hist(x, bins=40)
>>> title('histogram of random numbers')
 
Matplotlib gallery
Scipy Cookbook
Thanks for the attention!!
   PyLab ­ http://www.scipy.org/PyLab 
   matplotlib ­ http://matplotlib.sourceforge.net/ 
   scipy ­ http://www.scipy.org/ 
   numpy ­ http://numpy.scipy.org/ 
   ipython ­ http://ipython.scipy.org/moin/ 


   These slides: http://bioinfoblog.it 

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

RDM 2020: Python, Numpy, and Pandas
RDM 2020: Python, Numpy, and PandasRDM 2020: Python, Numpy, and Pandas
RDM 2020: Python, Numpy, and Pandas
 
Introduction to NumPy (PyData SV 2013)
Introduction to NumPy (PyData SV 2013)Introduction to NumPy (PyData SV 2013)
Introduction to NumPy (PyData SV 2013)
 
Numpy tutorial
Numpy tutorialNumpy tutorial
Numpy tutorial
 
Introduction to matplotlib
Introduction to matplotlibIntroduction to matplotlib
Introduction to matplotlib
 
Python NumPy Tutorial | NumPy Array | Edureka
Python NumPy Tutorial | NumPy Array | EdurekaPython NumPy Tutorial | NumPy Array | Edureka
Python NumPy Tutorial | NumPy Array | Edureka
 
Data Visualization(s) Using Python
Data Visualization(s) Using PythonData Visualization(s) Using Python
Data Visualization(s) Using Python
 
Python - Numpy/Pandas/Matplot Machine Learning Libraries
Python - Numpy/Pandas/Matplot Machine Learning LibrariesPython - Numpy/Pandas/Matplot Machine Learning Libraries
Python - Numpy/Pandas/Matplot Machine Learning Libraries
 
Python Seaborn Data Visualization
Python Seaborn Data Visualization Python Seaborn Data Visualization
Python Seaborn Data Visualization
 
Basic of python for data analysis
Basic of python for data analysisBasic of python for data analysis
Basic of python for data analysis
 
Introduction to python programming
Introduction to python programmingIntroduction to python programming
Introduction to python programming
 
Python Scipy Numpy
Python Scipy NumpyPython Scipy Numpy
Python Scipy Numpy
 
NumPy
NumPyNumPy
NumPy
 
Data Structures in Python
Data Structures in PythonData Structures in Python
Data Structures in Python
 
A Beginner's Guide to Machine Learning with Scikit-Learn
A Beginner's Guide to Machine Learning with Scikit-LearnA Beginner's Guide to Machine Learning with Scikit-Learn
A Beginner's Guide to Machine Learning with Scikit-Learn
 
Python 3 Programming Language
Python 3 Programming LanguagePython 3 Programming Language
Python 3 Programming Language
 
Introduction to Machine Learning with SciKit-Learn
Introduction to Machine Learning with SciKit-LearnIntroduction to Machine Learning with SciKit-Learn
Introduction to Machine Learning with SciKit-Learn
 
Python Functions
Python   FunctionsPython   Functions
Python Functions
 
Introduction to Python Pandas for Data Analytics
Introduction to Python Pandas for Data AnalyticsIntroduction to Python Pandas for Data Analytics
Introduction to Python Pandas for Data Analytics
 
Scikit Learn intro
Scikit Learn introScikit Learn intro
Scikit Learn intro
 
Seaborn.pptx
Seaborn.pptxSeaborn.pptx
Seaborn.pptx
 

Semelhante a Plotting data with python and pylab

Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
DRVaibhavmeshram1
 
Lecture 5 – Computing with Numbers (Math Lib).pptx
Lecture 5 – Computing with Numbers (Math Lib).pptxLecture 5 – Computing with Numbers (Math Lib).pptx
Lecture 5 – Computing with Numbers (Math Lib).pptx
jovannyflex
 
Python Interview Questions | Python Interview Questions And Answers | Python ...
Python Interview Questions | Python Interview Questions And Answers | Python ...Python Interview Questions | Python Interview Questions And Answers | Python ...
Python Interview Questions | Python Interview Questions And Answers | Python ...
Simplilearn
 
Python bootcamp - C4Dlab, University of Nairobi
Python bootcamp - C4Dlab, University of NairobiPython bootcamp - C4Dlab, University of Nairobi
Python bootcamp - C4Dlab, University of Nairobi
krmboya
 

Semelhante a Plotting data with python and pylab (20)

A Gentle Introduction to Coding ... with Python
A Gentle Introduction to Coding ... with PythonA Gentle Introduction to Coding ... with Python
A Gentle Introduction to Coding ... with Python
 
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
Introduction to Python 01-08-2023.pon by everyone else. . Hence, they must be...
 
Python For Scientists
Python For ScientistsPython For Scientists
Python For Scientists
 
iPython
iPythoniPython
iPython
 
Scientific Python
Scientific PythonScientific Python
Scientific Python
 
Matplotlib
MatplotlibMatplotlib
Matplotlib
 
Biopython: Overview, State of the Art and Outlook
Biopython: Overview, State of the Art and OutlookBiopython: Overview, State of the Art and Outlook
Biopython: Overview, State of the Art and Outlook
 
Lecture 5 – Computing with Numbers (Math Lib).pptx
Lecture 5 – Computing with Numbers (Math Lib).pptxLecture 5 – Computing with Numbers (Math Lib).pptx
Lecture 5 – Computing with Numbers (Math Lib).pptx
 
Lecture 5 – Computing with Numbers (Math Lib).pptx
Lecture 5 – Computing with Numbers (Math Lib).pptxLecture 5 – Computing with Numbers (Math Lib).pptx
Lecture 5 – Computing with Numbers (Math Lib).pptx
 
python lab programs.pdf
python lab programs.pdfpython lab programs.pdf
python lab programs.pdf
 
Introduction to Pylab and Matploitlib.
Introduction to Pylab and Matploitlib. Introduction to Pylab and Matploitlib.
Introduction to Pylab and Matploitlib.
 
Project gnuplot
Project gnuplotProject gnuplot
Project gnuplot
 
Lecture 9.pptx
Lecture 9.pptxLecture 9.pptx
Lecture 9.pptx
 
PPT on Data Science Using Python
PPT on Data Science Using PythonPPT on Data Science Using Python
PPT on Data Science Using Python
 
Python Interview Questions | Python Interview Questions And Answers | Python ...
Python Interview Questions | Python Interview Questions And Answers | Python ...Python Interview Questions | Python Interview Questions And Answers | Python ...
Python Interview Questions | Python Interview Questions And Answers | Python ...
 
Numerical tour in the Python eco-system: Python, NumPy, scikit-learn
Numerical tour in the Python eco-system: Python, NumPy, scikit-learnNumerical tour in the Python eco-system: Python, NumPy, scikit-learn
Numerical tour in the Python eco-system: Python, NumPy, scikit-learn
 
First Steps in Python Programming
First Steps in Python ProgrammingFirst Steps in Python Programming
First Steps in Python Programming
 
Course set three full notes
Course set three full notesCourse set three full notes
Course set three full notes
 
DS LAB MANUAL.pdf
DS LAB MANUAL.pdfDS LAB MANUAL.pdf
DS LAB MANUAL.pdf
 
Python bootcamp - C4Dlab, University of Nairobi
Python bootcamp - C4Dlab, University of NairobiPython bootcamp - C4Dlab, University of Nairobi
Python bootcamp - C4Dlab, University of Nairobi
 

Mais de Giovanni Marco Dall'Olio

The true story behind the annotation of a pathway
The true story behind the annotation of a pathwayThe true story behind the annotation of a pathway
The true story behind the annotation of a pathway
Giovanni Marco Dall'Olio
 

Mais de Giovanni Marco Dall'Olio (20)

Fehrman Nat Gen 2014 - Journal Club
Fehrman Nat Gen 2014 - Journal ClubFehrman Nat Gen 2014 - Journal Club
Fehrman Nat Gen 2014 - Journal Club
 
Thesis defence of Dall'Olio Giovanni Marco. Applications of network theory to...
Thesis defence of Dall'Olio Giovanni Marco. Applications of network theory to...Thesis defence of Dall'Olio Giovanni Marco. Applications of network theory to...
Thesis defence of Dall'Olio Giovanni Marco. Applications of network theory to...
 
Agile bioinf
Agile bioinfAgile bioinf
Agile bioinf
 
Version control
Version controlVersion control
Version control
 
Linux intro 5 extra: awk
Linux intro 5 extra: awkLinux intro 5 extra: awk
Linux intro 5 extra: awk
 
Linux intro 5 extra: makefiles
Linux intro 5 extra: makefilesLinux intro 5 extra: makefiles
Linux intro 5 extra: makefiles
 
Linux intro 4 awk + makefile
Linux intro 4  awk + makefileLinux intro 4  awk + makefile
Linux intro 4 awk + makefile
 
Linux intro 3 grep + Unix piping
Linux intro 3 grep + Unix pipingLinux intro 3 grep + Unix piping
Linux intro 3 grep + Unix piping
 
Linux intro 2 basic terminal
Linux intro 2   basic terminalLinux intro 2   basic terminal
Linux intro 2 basic terminal
 
Linux intro 1 definitions
Linux intro 1  definitionsLinux intro 1  definitions
Linux intro 1 definitions
 
Wagner chapter 5
Wagner chapter 5Wagner chapter 5
Wagner chapter 5
 
Wagner chapter 4
Wagner chapter 4Wagner chapter 4
Wagner chapter 4
 
Wagner chapter 3
Wagner chapter 3Wagner chapter 3
Wagner chapter 3
 
Wagner chapter 2
Wagner chapter 2Wagner chapter 2
Wagner chapter 2
 
Wagner chapter 1
Wagner chapter 1Wagner chapter 1
Wagner chapter 1
 
Hg for bioinformatics, second part
Hg for bioinformatics, second partHg for bioinformatics, second part
Hg for bioinformatics, second part
 
Hg version control bioinformaticians
Hg version control bioinformaticiansHg version control bioinformaticians
Hg version control bioinformaticians
 
The true story behind the annotation of a pathway
The true story behind the annotation of a pathwayThe true story behind the annotation of a pathway
The true story behind the annotation of a pathway
 
Pycon
PyconPycon
Pycon
 
Makefiles Bioinfo
Makefiles BioinfoMakefiles Bioinfo
Makefiles Bioinfo
 

Último

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Último (20)

Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
JohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptxJohnPollard-hybrid-app-RailsConf2024.pptx
JohnPollard-hybrid-app-RailsConf2024.pptx
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 

Plotting data with python and pylab

  • 1. Barcelona Python Meetup Plotting data with python and pylab Giovanni M. Dall'Olio
  • 2. Problem statement  Let's say we have a table of data like this: name country apples pears Giovanni Italy 31 13 Mario Italy 23 33 Luigi Italy 0 5 Margaret England 22 13 Albert Germany 15 6  How to read it in python?  How to do some basic plotting?
  • 3. Alternatives for plotting data in python  Pylab (enthought)→ Matlab/Octave approach  Enthought → extended version of Pylab (free for  academic use)  rpy/rpy2 → allows to run R commands within  python  Sage → interfaces python with Matlab, R, octave,  mathematica, ...
  • 4. The Pylab system  pylab is a system of three libraries, which together  transform python in a Matlab­like environment  It is composed by:  Numpy (arrays, matrices, complex numbers, etc.. in  python)  Scipy (extended scientific/statistics functions)  Matplotlib (plotting library)  iPython (extended interactive interpreter)
  • 5. How to install pylab  There are many alternatives to install PyLab:  use the package manager of your linux distro   use enthought's distribution ( http://www.enthought.com/products/epd.php) (free  for academic use)  compile and google for help!  Numpy and scipy contains some Fortran libraries,  therefore easy_install doesn't work well with  them
  • 6. ipython -pylab  Ipython is an extended version of the standard  python interpreter  It has a modality especially designed for pylab  The standard python interpreter doesn't support  very well plotting (not multi­threading)  So if you want an interactive interpreter, use  ipython with the pylab option:      $: alias pylab=”ipython -pylab” $: pylab In [1]:
  • 7. Why the python interpreter is not the best for plotting Gets blocked when you create a plot
  • 8. How to read a CSV file with python  To read a file like this in pylab: name country apples pears Giovanni Italy 31 13 Mario Italy 23 33 Luigi Italy 0 5 Margaret England 22 13 Albert Germany 15 6  → Use the function 'matplotlib.mlab.csv2rec' >>> data = csv2rec('exampledata.txt', delimiter='t')
  • 9. Numpy - record arrays  csv2rec stores data in a numpy recarray object, where  you can access columns and rows easily: >>> print data['name'] ['Giovanni' 'Mario' 'Luigi' 'Margaret' 'Albert'] >>> data['apples'] array([31, 23, 0, 22, 15]) >>> data[1] ('Mario', 'Italy', 23, 33)
  • 10. Alternative to csv2rec  numpy.genfromtxt (new in 2009)  More options than csv2rec, included in numpy  Tricky default parameters: need to specify dtype=None >>> data = numpy.genfromtxt('datafile.txt', dtype=None) >>> data array....
  • 11. Barchart >>> data = csv2rec('exampledata.txt', delimiter='t') >>> bar(arange(len(data)), data['apples'], color='red', width=0.1, label='apples') >>> bar(arange(len(data))+0.1, data['pears'], color='blue', width=0.1, label='pears') >>> xticks(range(len(data)), data['name'], ) >>> legend() >>> grid('.')
  • 12. Barchart >>> data = csv2rec('exampledata.txt', delimiter='t') >>> figure() >>> clf() Read a CSV file and storing  it in a recordarray object Use figure() and cls() to  reset the graphic device
  • 13. Barchart >>> data = csv2rec('exampledata.txt', delimiter='t') >>> bar(x=arange(len(data)), y=data['apples'], color='red', width=0.1, label='apples')  The bar function creates a  barchart
  • 14. Barchart >>> data = csv2rec('exampledata.txt', delimiter='t') >>> bar(x=arange(len(data)), y=data['apples'], color='red', width=0.1, label='apples') >>> bar(arange(len(data))+0.1, data['pears'], color='blue', width=0.1, label='pears')  This is the second barchart
  • 15. Barchart >>> data = csv2rec('exampledata.txt', delimiter='t') >>> bar(x=arange(len(data)), y=data['apples'], color='red', width=0.1, label='apples') >>> bar(arange(len(data))+0.1, data['pears'], color='blue', width=0.1, label='pears') >>> xticks(range(len(data)), data['name'], )  Re­defining the labels in the X axis  (xticks)
  • 16. Barchart >>> data = csv2rec('exampledata.txt', delimiter='t') >>> bar(x=arange(len(data)), y=data['apples'], color='red', width=0.1, label='apples') >>> bar(arange(len(data))+0.1, data['pears'], color='blue', width=0.1, label='pears') >>> xticks(range(len(data)), data['name'], ) >>> legend() >>> grid('.') >>> title('apples and pears by person')  Adding legend, grid, title
  • 18. Pie Chart >>> pie(data['pears'], labels=data['name']) >>> pie(data['pears'], labels=['%sn(%s pears)' % (i,j) for (i, j) in zip(data['name'], data['pears'])] )
  • 20. A plot chart >>> x = linspace(1,10, 10) >>> y = randn(10) >>> plot(x,y, 'r.', ms=15)  
  • 21. An histogram >>> x = randn(1000) >>> hist(x, bins=40) >>> title('histogram of random numbers')  
  • 24. Thanks for the attention!!  PyLab ­ http://www.scipy.org/PyLab   matplotlib ­ http://matplotlib.sourceforge.net/   scipy ­ http://www.scipy.org/   numpy ­ http://numpy.scipy.org/   ipython ­ http://ipython.scipy.org/moin/   These slides: http://bioinfoblog.it