SlideShare a Scribd company logo
“ use the matplotlib, luke ”
            Wen-Wei Liao
          gattacaliao@gmail.com
A long time ago, in a galaxy far, far away ...
NO!
 John Hunter
“   Matplotlib is a Python 2D plotting package which
    produces publication quality figures in a variety of
    hardcopy formats and interactive environments
    across platforms.
Philosophy
       create simple plots with just a few commands, or
                           just one!




import numpy as np
import matplotlib.pyplot as plt


x = np.random.randn(10000)
plt.hist(x, bins=50)
plt.show()
object-oriented
                  interface



FigureCanvas


 Renderer

   Artist      state-machine
                  interface
   pyplot
pyplot provides a MATLAB-style              pylab lumps pyplot together with
state-machine interface to the underlying   numpy in a single namespace, making
object-oriented interface in matplotlib     that environment even more MATLAB-like

 import numpy as np                          from pylab import *
 import matplotlib.pyplot as plt


 x = np.arange(0, 10, 0.1)                   x = arange(0, 10, 0.1)
 y = np.sin(x)                               y = sin(x)
 plt.plot(x, y)                              plot(x, y)
 plt.show()                                  show()
Explicit is better than implicit.
preferred style using pyplot convenience functions,
but object-orientation for the rest

import numpy as np
import matplotlib.pyplot as plt


x = np.arange(0, 10, 0.1)
y = np.sin(x)
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(x, y)
plt.show()
2 types of Artists

•   Primitives: Line2D, Rectangle, Text, etc.

•   Containers: Figure, Axes, Axis, Tick




    http://sfillustration.wordpress.com/2012/02/25/star-wars
Figure Container
(matplotlib.figure.Figure)
Axes Container
(matplotlib.axes.Axes)
XAxis Container
(matplotlib.axis.Axis)
YAxis Container
(matplotlib.axis.Axis)
XTick Container
(matplotlib.axis.Tick)
YTick Container
(matplotlib.axis.Tick)
Customizing your objects

each of the properties is accessed with an old-fashioned
setter or getter
a = o.get_alpha()
o.set_alpha(0.5*a)




set a number of properties at once
o.set(alpha=0.5, zorder=2)
import matplotlib.pyplot as plt


fig = plt.figure()
ax = fig.add_subplot(111)


for label in ax.xaxis.get_ticklabels():
    # label is a Text instance
    label.set_color(‘red’)
    label.set_rotation(45)
    label.set_fontsize(20)
    label.set_fontweight(‘bold’)


for line in ax.yaxis.get_ticklines():
    # line is a Line2D instance
    line.set_color(‘green’)
    line.set_markersize(30)
    line.set_markeredgewidth(5)


plt.show()
import matplotlib.pyplot as plt


fig = plt.figure()
ax = fig.add_subplot(111)


for tick in ax.yaxis.get_major_ticks():
    tick.label1On = False
    tick.label2On = True
    tick.label2.set_color(‘blue’)
    tick.label2.set_fontsize(20)
    tick.label2.set_fontweight(‘bold’)


    tick.gridOn = True
    tick.gridline.set_color(‘red’)
    tick.gridline.set_linewidth(2)
    tick.gridline.set_linestyle(‘--’)


plt.show()
import matplotlib.pyplot as plt


fig = plt.figure()
ax = fig.add_subplot(111)


ax.spines[‘top’].set_visible(False)
ax.spines[‘right’].set_visible(False)
ax.spines[‘bottom’].set_position(‘center’)
ax.spines[‘left’].set_position(‘center’)


for tick in ax.xaxis.get_major_ticks():
    tick.tick2On = False


for tick in ax.yaxis.get_major_ticks():
    tick.tick2On = False


plt.show()
Customizing location of Axes




ax1   =   fig.add_subplot(221)
ax2   =   fig.add_subplot(222)
ax3   =   fig.add_subplot(223)
ax4   =   fig.add_subplot(224)
Customizing location of Axes




# add_axes((left, bottom, width, height))


ax1   =   fig.add_axes((0.1, 0.1, 0.2, 0.8))
ax2   =   fig.add_axes((0.35, 0.55, 0.55, 0.35))
ax3   =   fig.add_axes((0.35, 0.1, 0.3, 0.4))
ax4   =   fig.add_axes((0.7, 0.1, 0.2, 0.4))
FREE!
The memory required for a figure is not completely
released until the figure is explicitly closed with close().

     import os
     import glob
     import matplotlib.pyplot as plt


     filelist = glob.glob(‘*.txt’)
     for fname in filelist:


                 ...
                 ...
                 ...


         fig = plt.figure()
         ax = fig.add_subplot(111)
         ax.plot(x, y)
         plt.savefig(os.path.splitext(fname)[0])
         plt.close(fig)
Signal propagation




• Vogels TP, Abbott LF (2005) Signal propagation and logic gating in networks of integrate-and-fire neurons. J Neurosci 25: 10786-10795.
• Brian: a simulator for spiking neural networks in Python (http://briansimulator.org)
Hierarchical clustering
mpl_toolkits.mplot3d
provides some basic 3D plotting tools
May the Matplotlib be with You :)

More Related Content

What's hot

Python Matplotlib Tutorial | Matplotlib Tutorial | Python Tutorial | Python T...
Python Matplotlib Tutorial | Matplotlib Tutorial | Python Tutorial | Python T...Python Matplotlib Tutorial | Matplotlib Tutorial | Python Tutorial | Python T...
Python Matplotlib Tutorial | Matplotlib Tutorial | Python Tutorial | Python T...
Edureka!
 
Plotting data with python and pylab
Plotting data with python and pylabPlotting data with python and pylab
Plotting data with python and pylab
Giovanni Marco Dall'Olio
 
Introduction to numpy Session 1
Introduction to numpy Session 1Introduction to numpy Session 1
Introduction to numpy Session 1
Jatin Miglani
 
The TensorFlow dance craze
The TensorFlow dance crazeThe TensorFlow dance craze
The TensorFlow dance craze
Gabriel Hamilton
 
NumPy/SciPy Statistics
NumPy/SciPy StatisticsNumPy/SciPy Statistics
NumPy/SciPy Statistics
Enthought, Inc.
 
Python Scipy Numpy
Python Scipy NumpyPython Scipy Numpy
Python Scipy Numpy
Girish Khanzode
 
Gnuplot 2
Gnuplot 2Gnuplot 2
Gnuplot 2
FarkhandaAna
 
Python for Scientific Computing -- Ricardo Cruz
Python for Scientific Computing -- Ricardo CruzPython for Scientific Computing -- Ricardo Cruz
Python for Scientific Computing -- Ricardo Cruz
rpmcruz
 
Introduction to numpy
Introduction to numpyIntroduction to numpy
Introduction to numpy
Gaurav Aggarwal
 
NumPy
NumPyNumPy
PYTHON-Chapter 4-Plotting and Data Science PyLab - MAULIK BORSANIYA
PYTHON-Chapter 4-Plotting and Data Science  PyLab - MAULIK BORSANIYAPYTHON-Chapter 4-Plotting and Data Science  PyLab - MAULIK BORSANIYA
PYTHON-Chapter 4-Plotting and Data Science PyLab - MAULIK BORSANIYA
Maulik Borsaniya
 
Effective Numerical Computation in NumPy and SciPy
Effective Numerical Computation in NumPy and SciPyEffective Numerical Computation in NumPy and SciPy
Effective Numerical Computation in NumPy and SciPy
Kimikazu Kato
 
Introduction to NumPy (PyData SV 2013)
Introduction to NumPy (PyData SV 2013)Introduction to NumPy (PyData SV 2013)
Introduction to NumPy (PyData SV 2013)
PyData
 
Introduction to Pylab and Matploitlib.
Introduction to Pylab and Matploitlib. Introduction to Pylab and Matploitlib.
Introduction to Pylab and Matploitlib.
yazad dumasia
 
Numpy
NumpyNumpy
Gopher conbr golang e data science - oficial
Gopher conbr   golang e data science - oficialGopher conbr   golang e data science - oficial
Gopher conbr golang e data science - oficial
Rodrigo Pinheiro
 
Matplotlib demo code
Matplotlib demo codeMatplotlib demo code
Matplotlib demo code
pythonsd
 
Functional Programming, simplified
Functional Programming, simplifiedFunctional Programming, simplified
Functional Programming, simplified
Naveenkumar Muguda
 
"PyTorch Deep Learning Framework: Status and Directions," a Presentation from...
"PyTorch Deep Learning Framework: Status and Directions," a Presentation from..."PyTorch Deep Learning Framework: Status and Directions," a Presentation from...
"PyTorch Deep Learning Framework: Status and Directions," a Presentation from...
Edge AI and Vision Alliance
 
Dma
DmaDma

What's hot (20)

Python Matplotlib Tutorial | Matplotlib Tutorial | Python Tutorial | Python T...
Python Matplotlib Tutorial | Matplotlib Tutorial | Python Tutorial | Python T...Python Matplotlib Tutorial | Matplotlib Tutorial | Python Tutorial | Python T...
Python Matplotlib Tutorial | Matplotlib Tutorial | Python Tutorial | Python T...
 
Plotting data with python and pylab
Plotting data with python and pylabPlotting data with python and pylab
Plotting data with python and pylab
 
Introduction to numpy Session 1
Introduction to numpy Session 1Introduction to numpy Session 1
Introduction to numpy Session 1
 
The TensorFlow dance craze
The TensorFlow dance crazeThe TensorFlow dance craze
The TensorFlow dance craze
 
NumPy/SciPy Statistics
NumPy/SciPy StatisticsNumPy/SciPy Statistics
NumPy/SciPy Statistics
 
Python Scipy Numpy
Python Scipy NumpyPython Scipy Numpy
Python Scipy Numpy
 
Gnuplot 2
Gnuplot 2Gnuplot 2
Gnuplot 2
 
Python for Scientific Computing -- Ricardo Cruz
Python for Scientific Computing -- Ricardo CruzPython for Scientific Computing -- Ricardo Cruz
Python for Scientific Computing -- Ricardo Cruz
 
Introduction to numpy
Introduction to numpyIntroduction to numpy
Introduction to numpy
 
NumPy
NumPyNumPy
NumPy
 
PYTHON-Chapter 4-Plotting and Data Science PyLab - MAULIK BORSANIYA
PYTHON-Chapter 4-Plotting and Data Science  PyLab - MAULIK BORSANIYAPYTHON-Chapter 4-Plotting and Data Science  PyLab - MAULIK BORSANIYA
PYTHON-Chapter 4-Plotting and Data Science PyLab - MAULIK BORSANIYA
 
Effective Numerical Computation in NumPy and SciPy
Effective Numerical Computation in NumPy and SciPyEffective Numerical Computation in NumPy and SciPy
Effective Numerical Computation in NumPy and SciPy
 
Introduction to NumPy (PyData SV 2013)
Introduction to NumPy (PyData SV 2013)Introduction to NumPy (PyData SV 2013)
Introduction to NumPy (PyData SV 2013)
 
Introduction to Pylab and Matploitlib.
Introduction to Pylab and Matploitlib. Introduction to Pylab and Matploitlib.
Introduction to Pylab and Matploitlib.
 
Numpy
NumpyNumpy
Numpy
 
Gopher conbr golang e data science - oficial
Gopher conbr   golang e data science - oficialGopher conbr   golang e data science - oficial
Gopher conbr golang e data science - oficial
 
Matplotlib demo code
Matplotlib demo codeMatplotlib demo code
Matplotlib demo code
 
Functional Programming, simplified
Functional Programming, simplifiedFunctional Programming, simplified
Functional Programming, simplified
 
"PyTorch Deep Learning Framework: Status and Directions," a Presentation from...
"PyTorch Deep Learning Framework: Status and Directions," a Presentation from..."PyTorch Deep Learning Framework: Status and Directions," a Presentation from...
"PyTorch Deep Learning Framework: Status and Directions," a Presentation from...
 
Dma
DmaDma
Dma
 

Viewers also liked

Data Visualization in matplotlib
Data Visualization in matplotlibData Visualization in matplotlib
Data Visualization in matplotlib
Bartosz Telenczuk
 
Poscat seminar 10
Poscat seminar 10Poscat seminar 10
Poscat seminar 10
Hyungyu Shin
 
GR.jl - Plotting for Julia based on GR
GR.jl - Plotting for Julia based on GRGR.jl - Plotting for Julia based on GR
GR.jl - Plotting for Julia based on GR
Josef Heinen
 
Quantitative management minimal spanning tree and dijkstra
Quantitative management minimal spanning tree and dijkstraQuantitative management minimal spanning tree and dijkstra
Quantitative management minimal spanning tree and dijkstraadarsh
 
Life after Matplotlib: Harder, Better, Faster, Stronger by Kayla Lacovino
Life after Matplotlib: Harder, Better, Faster, Stronger by Kayla LacovinoLife after Matplotlib: Harder, Better, Faster, Stronger by Kayla Lacovino
Life after Matplotlib: Harder, Better, Faster, Stronger by Kayla Lacovino
PyData
 
Introduction to plotting in Python
Introduction to plotting in Python Introduction to plotting in Python
Introduction to plotting in Python
bzamecnik
 
Dijkastra’s algorithm
Dijkastra’s algorithmDijkastra’s algorithm
Dijkastra’s algorithm
Pulkit Goel
 
Networks dijkstra's algorithm- pgsr
Networks  dijkstra's algorithm- pgsrNetworks  dijkstra's algorithm- pgsr
Networks dijkstra's algorithm- pgsrLinawati Adiman
 

Viewers also liked (10)

Data Visualization in matplotlib
Data Visualization in matplotlibData Visualization in matplotlib
Data Visualization in matplotlib
 
Poscat seminar 10
Poscat seminar 10Poscat seminar 10
Poscat seminar 10
 
GR.jl - Plotting for Julia based on GR
GR.jl - Plotting for Julia based on GRGR.jl - Plotting for Julia based on GR
GR.jl - Plotting for Julia based on GR
 
Quantitative management minimal spanning tree and dijkstra
Quantitative management minimal spanning tree and dijkstraQuantitative management minimal spanning tree and dijkstra
Quantitative management minimal spanning tree and dijkstra
 
Life after Matplotlib: Harder, Better, Faster, Stronger by Kayla Lacovino
Life after Matplotlib: Harder, Better, Faster, Stronger by Kayla LacovinoLife after Matplotlib: Harder, Better, Faster, Stronger by Kayla Lacovino
Life after Matplotlib: Harder, Better, Faster, Stronger by Kayla Lacovino
 
Introduction to plotting in Python
Introduction to plotting in Python Introduction to plotting in Python
Introduction to plotting in Python
 
Dijkastra’s algorithm
Dijkastra’s algorithmDijkastra’s algorithm
Dijkastra’s algorithm
 
Networks dijkstra's algorithm- pgsr
Networks  dijkstra's algorithm- pgsrNetworks  dijkstra's algorithm- pgsr
Networks dijkstra's algorithm- pgsr
 
Dijekstra algorithm
Dijekstra algorithmDijekstra algorithm
Dijekstra algorithm
 
graph theory
graph theory graph theory
graph theory
 

Similar to Use the Matplotlib, Luke @ PyCon Taiwan 2012

Py lecture5 python plots
Py lecture5 python plotsPy lecture5 python plots
Py lecture5 python plots
Yoshiki Satotani
 
Introduction to Data Visualization,Matplotlib.pdf
Introduction to Data Visualization,Matplotlib.pdfIntroduction to Data Visualization,Matplotlib.pdf
Introduction to Data Visualization,Matplotlib.pdf
sumitt6_25730773
 
MatplotLib.pptx
MatplotLib.pptxMatplotLib.pptx
MatplotLib.pptx
Paras Intotech
 
Visualization and Matplotlib using Python.pptx
Visualization and Matplotlib using Python.pptxVisualization and Matplotlib using Python.pptx
Visualization and Matplotlib using Python.pptx
SharmilaMore5
 
Python matplotlib cheat_sheet
Python matplotlib cheat_sheetPython matplotlib cheat_sheet
Python matplotlib cheat_sheet
Nishant Upadhyay
 
Numba: Array-oriented Python Compiler for NumPy
Numba: Array-oriented Python Compiler for NumPyNumba: Array-oriented Python Compiler for NumPy
Numba: Array-oriented Python Compiler for NumPy
Travis Oliphant
 
matplotlib-installatin-interactive-contour-example-guide
matplotlib-installatin-interactive-contour-example-guidematplotlib-installatin-interactive-contour-example-guide
matplotlib-installatin-interactive-contour-example-guideArulalan T
 
Python과 node.js기반 데이터 분석 및 가시화
Python과 node.js기반 데이터 분석 및 가시화Python과 node.js기반 데이터 분석 및 가시화
Python과 node.js기반 데이터 분석 및 가시화
Tae wook kang
 
Python programing
Python programingPython programing
Python programing
BHAVYA DOSHI
 
14-visualization.pptx
14-visualization.pptx14-visualization.pptx
14-visualization.pptx
ssuser6e6eec
 
Pydiomatic
PydiomaticPydiomatic
Pydiomatic
rik0
 
Python idiomatico
Python idiomaticoPython idiomatico
Python idiomatico
PyCon Italia
 
Python for Machine Learning(MatPlotLib).pptx
Python for Machine Learning(MatPlotLib).pptxPython for Machine Learning(MatPlotLib).pptx
Python for Machine Learning(MatPlotLib).pptx
Dr. Amanpreet Kaur
 
Real Time Big Data Management
Real Time Big Data ManagementReal Time Big Data Management
Real Time Big Data Management
Albert Bifet
 
The Ring programming language version 1.3 book - Part 84 of 88
The Ring programming language version 1.3 book - Part 84 of 88The Ring programming language version 1.3 book - Part 84 of 88
The Ring programming language version 1.3 book - Part 84 of 88
Mahmoud Samir Fayed
 
Python seaborn cheat_sheet
Python seaborn cheat_sheetPython seaborn cheat_sheet
Python seaborn cheat_sheet
Nishant Upadhyay
 
Python 培训讲义
Python 培训讲义Python 培训讲义
Python 培训讲义
leejd
 

Similar to Use the Matplotlib, Luke @ PyCon Taiwan 2012 (20)

Py lecture5 python plots
Py lecture5 python plotsPy lecture5 python plots
Py lecture5 python plots
 
Introduction to Data Visualization,Matplotlib.pdf
Introduction to Data Visualization,Matplotlib.pdfIntroduction to Data Visualization,Matplotlib.pdf
Introduction to Data Visualization,Matplotlib.pdf
 
MatplotLib.pptx
MatplotLib.pptxMatplotLib.pptx
MatplotLib.pptx
 
Visualization and Matplotlib using Python.pptx
Visualization and Matplotlib using Python.pptxVisualization and Matplotlib using Python.pptx
Visualization and Matplotlib using Python.pptx
 
Python matplotlib cheat_sheet
Python matplotlib cheat_sheetPython matplotlib cheat_sheet
Python matplotlib cheat_sheet
 
Numba: Array-oriented Python Compiler for NumPy
Numba: Array-oriented Python Compiler for NumPyNumba: Array-oriented Python Compiler for NumPy
Numba: Array-oriented Python Compiler for NumPy
 
matplotlib-installatin-interactive-contour-example-guide
matplotlib-installatin-interactive-contour-example-guidematplotlib-installatin-interactive-contour-example-guide
matplotlib-installatin-interactive-contour-example-guide
 
Python과 node.js기반 데이터 분석 및 가시화
Python과 node.js기반 데이터 분석 및 가시화Python과 node.js기반 데이터 분석 및 가시화
Python과 node.js기반 데이터 분석 및 가시화
 
Python programing
Python programingPython programing
Python programing
 
An introduction to scala
An introduction to scalaAn introduction to scala
An introduction to scala
 
Hw09 Hadoop + Clojure
Hw09   Hadoop + ClojureHw09   Hadoop + Clojure
Hw09 Hadoop + Clojure
 
Hadoop + Clojure
Hadoop + ClojureHadoop + Clojure
Hadoop + Clojure
 
14-visualization.pptx
14-visualization.pptx14-visualization.pptx
14-visualization.pptx
 
Pydiomatic
PydiomaticPydiomatic
Pydiomatic
 
Python idiomatico
Python idiomaticoPython idiomatico
Python idiomatico
 
Python for Machine Learning(MatPlotLib).pptx
Python for Machine Learning(MatPlotLib).pptxPython for Machine Learning(MatPlotLib).pptx
Python for Machine Learning(MatPlotLib).pptx
 
Real Time Big Data Management
Real Time Big Data ManagementReal Time Big Data Management
Real Time Big Data Management
 
The Ring programming language version 1.3 book - Part 84 of 88
The Ring programming language version 1.3 book - Part 84 of 88The Ring programming language version 1.3 book - Part 84 of 88
The Ring programming language version 1.3 book - Part 84 of 88
 
Python seaborn cheat_sheet
Python seaborn cheat_sheetPython seaborn cheat_sheet
Python seaborn cheat_sheet
 
Python 培训讲义
Python 培训讲义Python 培训讲义
Python 培训讲义
 

Recently uploaded

Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
Ana-Maria Mihalceanu
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
Pierluigi Pugliese
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 

Recently uploaded (20)

Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdfFIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
FIDO Alliance Osaka Seminar: Passkeys and the Road Ahead.pdf
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Monitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR EventsMonitoring Java Application Security with JDK Tools and JFR Events
Monitoring Java Application Security with JDK Tools and JFR Events
 
By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024By Design, not by Accident - Agile Venture Bolzano 2024
By Design, not by Accident - Agile Venture Bolzano 2024
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 

Use the Matplotlib, Luke @ PyCon Taiwan 2012

  • 1. “ use the matplotlib, luke ” Wen-Wei Liao gattacaliao@gmail.com
  • 2. A long time ago, in a galaxy far, far away ...
  • 4. Matplotlib is a Python 2D plotting package which produces publication quality figures in a variety of hardcopy formats and interactive environments across platforms.
  • 5. Philosophy create simple plots with just a few commands, or just one! import numpy as np import matplotlib.pyplot as plt x = np.random.randn(10000) plt.hist(x, bins=50) plt.show()
  • 6. object-oriented interface FigureCanvas Renderer Artist state-machine interface pyplot
  • 7. pyplot provides a MATLAB-style pylab lumps pyplot together with state-machine interface to the underlying numpy in a single namespace, making object-oriented interface in matplotlib that environment even more MATLAB-like import numpy as np from pylab import * import matplotlib.pyplot as plt x = np.arange(0, 10, 0.1) x = arange(0, 10, 0.1) y = np.sin(x) y = sin(x) plt.plot(x, y) plot(x, y) plt.show() show()
  • 8. Explicit is better than implicit.
  • 9. preferred style using pyplot convenience functions, but object-orientation for the rest import numpy as np import matplotlib.pyplot as plt x = np.arange(0, 10, 0.1) y = np.sin(x) fig = plt.figure() ax = fig.add_subplot(111) ax.plot(x, y) plt.show()
  • 10. 2 types of Artists • Primitives: Line2D, Rectangle, Text, etc. • Containers: Figure, Axes, Axis, Tick http://sfillustration.wordpress.com/2012/02/25/star-wars
  • 17. Customizing your objects each of the properties is accessed with an old-fashioned setter or getter a = o.get_alpha() o.set_alpha(0.5*a) set a number of properties at once o.set(alpha=0.5, zorder=2)
  • 18. import matplotlib.pyplot as plt fig = plt.figure() ax = fig.add_subplot(111) for label in ax.xaxis.get_ticklabels(): # label is a Text instance label.set_color(‘red’) label.set_rotation(45) label.set_fontsize(20) label.set_fontweight(‘bold’) for line in ax.yaxis.get_ticklines(): # line is a Line2D instance line.set_color(‘green’) line.set_markersize(30) line.set_markeredgewidth(5) plt.show()
  • 19. import matplotlib.pyplot as plt fig = plt.figure() ax = fig.add_subplot(111) for tick in ax.yaxis.get_major_ticks(): tick.label1On = False tick.label2On = True tick.label2.set_color(‘blue’) tick.label2.set_fontsize(20) tick.label2.set_fontweight(‘bold’) tick.gridOn = True tick.gridline.set_color(‘red’) tick.gridline.set_linewidth(2) tick.gridline.set_linestyle(‘--’) plt.show()
  • 20. import matplotlib.pyplot as plt fig = plt.figure() ax = fig.add_subplot(111) ax.spines[‘top’].set_visible(False) ax.spines[‘right’].set_visible(False) ax.spines[‘bottom’].set_position(‘center’) ax.spines[‘left’].set_position(‘center’) for tick in ax.xaxis.get_major_ticks(): tick.tick2On = False for tick in ax.yaxis.get_major_ticks(): tick.tick2On = False plt.show()
  • 21. Customizing location of Axes ax1 = fig.add_subplot(221) ax2 = fig.add_subplot(222) ax3 = fig.add_subplot(223) ax4 = fig.add_subplot(224)
  • 22. Customizing location of Axes # add_axes((left, bottom, width, height)) ax1 = fig.add_axes((0.1, 0.1, 0.2, 0.8)) ax2 = fig.add_axes((0.35, 0.55, 0.55, 0.35)) ax3 = fig.add_axes((0.35, 0.1, 0.3, 0.4)) ax4 = fig.add_axes((0.7, 0.1, 0.2, 0.4))
  • 23. FREE!
  • 24. The memory required for a figure is not completely released until the figure is explicitly closed with close(). import os import glob import matplotlib.pyplot as plt filelist = glob.glob(‘*.txt’) for fname in filelist: ... ... ... fig = plt.figure() ax = fig.add_subplot(111) ax.plot(x, y) plt.savefig(os.path.splitext(fname)[0]) plt.close(fig)
  • 25. Signal propagation • Vogels TP, Abbott LF (2005) Signal propagation and logic gating in networks of integrate-and-fire neurons. J Neurosci 25: 10786-10795. • Brian: a simulator for spiking neural networks in Python (http://briansimulator.org)
  • 28. May the Matplotlib be with You :)