Matplotlib: Difference between revisions

Content deleted Content added
No edit summary
m Reverted edits by 223.178.87.68 (talk) (HG) (3.4.13)
 
(336 intermediate revisions by more than 100 users not shown)
Line 1:
{{Short description|Library for creating visualizations in Python}}
{{Infobox Software|software
name = matplotlib
|logo name = Matplotlib
|screenshot logo = [[Image:Matplotlib logo.png|250px]]svg
| logo size = 300px
|caption = Example plot by matplotlib
| screenshot = File:Mpl screenshot figures and code.png
|author = John Hunter
| caption = Screenshot of Matplotlib plots and code
|latest release version = 0.98.5
| collapsible =
|latest release date = 2008-12-11
|operating_system author = [[Cross-platformJohn D. Hunter]]
| developer = Michael Droettboom, ''et al.''
|genre = [[List of graphing software|Plotting]]
|license released = [http{{Start date and age|df=yes|2003}}<ref>{{cite web|url=https://matplotlib.sourceforge.netorg/users/license.html#copyright-policy Own| freetitle=Copyright licence]Policy}}</ref>
| latest release version = {{wikidata|property|edit|reference|P348}}
|website = [http://matplotlib.sourceforge.net/ matplotlib.sf.net]
| latest release date = {{start date and age|{{wikidata|qualifier|P348|P577}}}}
| latest releasepreview version = 0.98.5
| latest releasepreview date = 2008-12-11
| engine = [[Cairo (graphics)| Cairo]], [[Anti-Grain Geometry]]
| discontinued =
| programming language = [[Python (programming language)|Python]]
| operating system = [[Cross-platform]]
| platform =
| size =
| language =
| genre = [[List of graphing software|Plotting]]
| license = [https://matplotlib.org/users/license.html Matplotlib license]
| website = {{URL|https://matplotlib.org}}
}}
'''Matplotlib''' (portmanteau of [[MATLAB]], plot, and library<ref>{{cite web | url=https://matplotlib.org/stable/project/history.html | title=History — Matplotlib 3.9.2 documentation }}</ref>) is a [[Plotter|plotting]] [[Library (computer science)|library]] for the [[Python (programming language)|Python]] [[programming language]] and its [[NumPy]]Numerical analysis|numerical mathematics]] extension [[NumPy]]. It provides aan "'''pylab'''"[[Object-oriented programming|object-oriented]] [[API]] designedfor toembedding closelyplots resembleinto thatapplications ofusing general-purpose [[MATLABGUI toolkit]]s like [[Tkinter]], thereby[[wxPython]], making[[Qt it(software)|Qt]], easyor to[[GTK]]. learnThere foris experiencedalso MATLABa users.[[Procedural Matplotlibprogramming|procedural]] is"pylab" writteninterface andbased maintainedon primarilya by[[state Johnmachine]] Hunter(like [[OpenGL]]), anddesigned isto distributedclosely underresemble athat BSDof [[MATLAB]], though its use is discouraged.<ref>{{cite web|title=API Overview|url=https://matplotlib.org/stable/api/index.html#module-stylepylab|publisher=matplotlib.org}}</ref> license[[SciPy]] makes use of Matplotlib.
 
Matplotlib was originally written by [[John D. Hunter]]. Since then it has had an active development community<ref>{{cite web |url=https://matplotlib.org/users/github_stats.html |title=Matplotlib github stats |publisher=matplotlib.org }}</ref> and is distributed under a [[BSD licenses|BSD-style license]]. Michael Droettboom was nominated as matplotlib's lead developer shortly before John Hunter's death in August 2012<ref>{{cite web |url=http://matplotlib.1069221.n5.nabble.com/ANN-Michael-Droettboom-matplotlib-lead-developer-td5037.html |title=Announcing Michael Droettboom as the lead Matplotlib developer |publisher=matplotlib.org |access-date=2013-04-24 |archive-date=2020-10-27 |archive-url=https://web.archive.org/web/20201027122844/http://matplotlib.1069221.n5.nabble.com/ANN-Michael-Droettboom-matplotlib-lead-developer-td5037.html |url-status=dead }}</ref> and was further joined by Thomas Caswell.<ref>{{Cite news|url=https://www.numfocus.org/blog/matplotlib-lead-developer-explains-why-he-cant-fix-the-docs-but-you-can|title=Matplotlib Lead Developer Explains Why He Can't Fix the Docs—But You Can – NumFOCUS|date=2017-10-05|work=NumFOCUS|access-date=2018-04-11|language=en-US}}</ref><ref>{{Cite web|url=https://matplotlib.org/users/credits.html|title=Credits – Matplotlib 2.2.2 documentation|website=matplotlib.org|access-date=2018-04-11}}</ref> Matplotlib is a [[NumFOCUS]] fiscally sponsored project.<ref>{{cite web|title=NumFOCUS Sponsored Projects|url=https://numfocus.org/sponsored-projects|publisher=NumFOCUS|access-date=2021-10-25}}</ref>
The "'''pylab'''" interface is procedural and based on a state machine, like [[OpenGL]]. There is also an [[Object-oriented programming|OOP]] interface which which is documented in the API Docs [http://matplotlib.sourceforge.net/api/index.html] which allows matplotlib plots to be embedded into applications using generic GUI toolkits, like [[wxPython]], [[Qt]] or [[GTK]].
 
== Usage ==
Currently, Matplotlib only has support for Python versions up to 2.5.
 
Matplotlib is used in scientific research as a tool for data visualization. For example, the [[Event Horizon Telescope]] collaboration used Matplotlib to produce visualizations during the effort to create the first image of a black hole.<ref name="NumPyBlackHole">{{cite web |title=Case Study: First Image of a Black Hole |url=https://numpy.org/case-studies/blackhole-image/ |website=NumPy |access-date=22 April 2025}}</ref> Matplotlib also underpins the plotting functionality of many scientific [[Python (programming language)|Python]] libraries (for instance, [[pandas (software)|pandas]] uses Matplotlib as its default backend for plotting). Its importance to the scientific community has been acknowledged by institutions such as [[NASA]], which in 2024 awarded a grant to support Matplotlib’s continued development as part of an initiative to fund widely used open-source scientific software.<ref name="NASAOpenSource">{{cite web |title=NASA Funds Open-Source Software Underpinning Scientific Innovation |url=https://www.nasa.gov/news-release/nasa-funds-open-source-software-underpinning-scientific-innovation/ |website=NASA |access-date=22 April 2025}}</ref>
== Comparison with MATLAB ==
 
[[File:Matplotlib in jupyter notebook.png|thumb|258x258px|A scatter plot created in Jupyter Notebook using Matplotlib]]
Matplotlib has become a viable alternative for many MATLAB users, and – like MATLAB before it – it is on its way to become a commonly used teaching tool for numerical mathematics and signal processing.
 
In education and data science, Matplotlib is frequently used to teach programming and data visualization. It integrates with [[Jupyter Notebook]], allowing students and instructors to generate inline plots and interactively explore data within a notebook environment.<ref name="JupyterNature">{{cite news |title=Interactive notebooks: Sharing the code |url=https://www.nature.com/articles/d41586-018-07196-1 |work=Nature |date=18 September 2018 |access-date=22 April 2025}}</ref> Many educational institutions incorporate Matplotlib into their curricula for teaching STEM concepts,<ref name="MatplotlibTutorial">{{cite web |title=Pyplot tutorial |url=https://matplotlib.org/stable/tutorials/introductory/pyplot.html |website=Matplotlib |access-date=22 April 2025}}</ref> and it is widely featured in tutorials, workshops, and open online courses as a primary plotting library.
Advantages of Python+NumPy+Matplotlib over MATLAB include:
 
==Related projects==
* Based on Python, a full-featured modern object-oriented programming language suitable for large-scale software development
* [[DISLIN]]
* Suitable for fast scripting, including [[Common Gateway Interface|CGI]] scripts
* Free, open source, no license servers
 
== Compare to ==
* [[GNU Octave]]
* [[Plotly]] – for interactive, online Matplotlib and Python graphs
* [http://code.enthought.com/chaco Chaco]
* [[PLplot]] – Python bindings available
* [[wxPython]] (module wx.lib.plot.py)
* [[SageMath]] – uses <code>Matplotlib</code> to draw plots
* [[Biggles (Python module)|Biggles]] [http://biggles.sourceforge.net/]
* [[DISLIN]]
* [[Gnuplot]]-py [http://gnuplot-py.sourceforge.net/]
* [[PyPlotter]] [http://www.eckhartarnold.de/apppages/pyplotter.html] – compatible with [[Jython]]
* [[PyX]] [http://pyx.sourceforge.net/]
* [[ReportLab]]
* [[SciPy]] (modules plt and gplt)
* [[PyCha]] [http://www.lorenzogil.com/projects/pycha/] - libcairo [http://www.cairographics.org/] implementation
 
==References==
== External links ==
{{Reflist|2}}
* [http://matplotlib.sourceforge.net/ Matplotlib Home Page]
* [http://www.scipy.org/Cookbook/Matplotlib/ Matplotlib Cookbook]
 
== External links ==
{{Commons category|Matplotlib}}
* {{Official website|https://matplotlib.org}}
 
{{SciPy ecosystem}}
 
[[Category:Articles with example Python (programming language) code]]
[[Category:Free plotting software]]
[[Category:PythonFree librariessoftware programmed in Python]]
[[Category:Python (programming language) scientific libraries]]
 
[[Category:Science software that uses GTK]]
{{free-software-stub}}
[[Category:Science software that uses Qt]]
 
[[Category:Free data and information visualization software]]
[[es:Matplotlib]]