For faster navigation, this Iframe is preloading the Wikiwand page for matplotlib.

matplotlib

matplotlib
開発元 John D. Hunter, Michael Droettboom など
最新版 3.9.2[1] ウィキデータを編集 - 2024年8月13日 (22日前) [±]
リポジトリ ウィキデータを編集
使用エンジン
  • cairo
ウィキデータを編集
プラットフォーム クロスプラットフォーム
種別 グラフ作成
ライセンス matplotlib licence
公式サイト matplotlib.org ウィキデータを編集
テンプレートを表示

Matplotlibは、プログラミング言語Pythonおよびその科学計算用ライブラリNumPyのためのグラフ描画ライブラリである。オブジェクト指向APIを提供しており、様々な種類のグラフを描画する能力を持つ。描画できるのは主に2次元のプロットだが、3次元プロットの機能も追加されてきている。描画したグラフを各種形式の画像(各種ベクトル画像形式も含む)として保存することもできるし、wxPythonQtGTKといった一般的なGUIツールキット製のアプリケーションにグラフの描画機能を組みこむこともできる。MATLABの対話環境のようなものを提供するpylabというインタフェースも持っている。Matplotlibは、BSDスタイルのライセンスの下で配布されている。

matplotlibは、Pythonのバージョン2.6以降、およびPython 3をサポートしている[2]。 matplotlib 1.1.x以前は、Pythonのバージョン2.4から2.7までをサポートしていた。

オリジナルの開発者であるJohn Hunterは、癌治療による合併症のため、2012年8月28日に死去した[3]。しかし、matplotlibの開発にはその他多数の人間が貢献しており、2012年11月9日には、Python 3を初めてサポートするバージョン1.2.0がリリースされた。John HunterにはPythonソフトウェア財団より特別功労賞 (The 2012 Distinguished Service Award) が贈られた[4]

MATLABとの比較

[編集]

matplotlibのpylabインタフェースは、MATLABの利用経験があるユーザがmatplotlibを簡単に習得できるように設計されている。

Python + Numpy + matplotlib + SciPy + etc. の組み合わせがMATLABに勝る点の例としては、以下のようなものが挙げられる。

  • MATLABのような特定用途向けの言語ではなく、大規模なソフトウェア開発も可能な現代的オブジェクト指向言語であるPythonをベースにしている。
  • 素早くスクリプトを書くのに向いている。CGIスクリプトを作ることもできる。
  • フリーかつオープンソースである。ライセンスサーバも必要ない。
  • ネイティブなSVGのサポート。

プロット例

[編集]

折れ線グラフ

>>> import matplotlib.pyplot as plt
>>> import numpy as np
>>> a = np.linspace(0,10,100)
>>> b = np.exp(-a)
>>> plt.plot(a,b)
>>> plt.show()

ヒストグラム

>>> import matplotlib.pyplot as plt
>>> from numpy.random import normal,rand
>>> x = normal(size=200)
>>> plt.hist(x,bins=30)
>>> plt.show()

散布図

>>> import matplotlib.pyplot as plt
>>> from numpy.random import rand
>>> a = rand(100)
>>> b = rand(100)
>>> plt.scatter(a,b)
>>> plt.show()

3Dグラフ

>>> from matplotlib import cm
>>> from mpl_toolkits.mplot3d import Axes3D
>>> import matplotlib.pyplot as plt
>>> import numpy as np
>>> fig = plt.figure()
>>> ax = fig.gca(projection='3d')
>>> X = np.arange(-5, 5, 0.25)
>>> Y = np.arange(-5, 5, 0.25)
>>> X, Y = np.meshgrid(X, Y)
>>> R = np.sqrt(X**2 + Y**2)
>>> Z = np.sin(R)
>>> surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.coolwarm)
>>> plt.show()

ツールキット

[編集]

Matplotlibの機能を拡張するためのいくつかのツールキットが存在する。Matplotlibのソースコードに付属するものもあれば、別途にダウンロードする必要のあるものもある。

  • Basemap: 様々な投影法・海岸線・政治的国境による地図の描画
    • 現在は cartopy の使用が推奨されている
  • Mplot3d: 3次元プロット
  • Natgrid: natgridライブラリ用のインタフェース
  • Excel tools: Microsoft Excelとのデータ交換を行なうユーティリティ
  • GTK tools: GTKライブラリ用のインタフェース

脚注

[編集]
  1. ^ "Release 3.9.2"; 閲覧日: 2024年8月22日; 出版日: 2024年8月13日.
  2. ^ What's new in matplotlib”. 2012年11月13日閲覧。
  3. ^ John Hunter Memorial Fund”. 2012年11月13日閲覧。
  4. ^ PSF Distinguished Service Awards”. 2013年2月16日閲覧。

外部リンク

[編集]
{{bottomLinkPreText}} {{bottomLinkText}}
matplotlib
Listen to this article

This browser is not supported by Wikiwand :(
Wikiwand requires a browser with modern capabilities in order to provide you with the best reading experience.
Please download and use one of the following browsers:

This article was just edited, click to reload
This article has been deleted on Wikipedia (Why?)

Back to homepage

Please click Add in the dialog above
Please click Allow in the top-left corner,
then click Install Now in the dialog
Please click Open in the download dialog,
then click Install
Please click the "Downloads" icon in the Safari toolbar, open the first download in the list,
then click Install
{{::$root.activation.text}}

Install Wikiwand

Install on Chrome Install on Firefox
Don't forget to rate us

Tell your friends about Wikiwand!

Gmail Facebook Twitter Link

Enjoying Wikiwand?

Tell your friends and spread the love:
Share on Gmail Share on Facebook Share on Twitter Share on Buffer

Our magic isn't perfect

You can help our automatic cover photo selection by reporting an unsuitable photo.

This photo is visually disturbing This photo is not a good choice

Thank you for helping!


Your input will affect cover photo selection, along with input from other users.

X

Get ready for Wikiwand 2.0 🎉! the new version arrives on September 1st! Don't want to wait?