1.1. Matplotlib About

1.1.1. What is matplotlib

Moduł matplotlib pozwala na rysowanie wykresów i diagramów. Jest to bardzo rozbudowana biblioteka z setkami opcji konfiguracyjnych. Najczęściej używanym modułem biblioteki matplotlib jest moduł pyplot, który implementuje szereg funkcji umożliwiających rysowanie wykresów 2d.

Pyplot's state-machine environment behaves similarly to MATLAB and should be most familiar to users with MATLAB experience.

Matplotlib is a Python 2D plotting library which produces publication-quality figures in a variety of hardcopy formats and interactive environments across platforms. Matplotlib can be used in Python scripts, the Python and IPython shell (à la MATLAB or Mathematica), web application servers, and various graphical user interface toolkits.

It provides an object-oriented API for embedding plots into applications using general-purpose GUI toolkits like Tkinter, wxPython, Qt, or GTK+. There is also a procedural "pylab" interface based on a state machine (like OpenGL), designed to closely resemble that of MATLAB, though its use is discouraged. SciPy makes use of matplotlib.

1.1.2. Install

$ pip install matplotlib

1.1.3. Usage

1.1.4. Import

import matplotlib.pyplot as plt

1.1.5. Running matplotlib in PyCharm

  • Scientific Mode

1.1.6. Running matplotlib in standalone scripts

  • Scale

  • Export to image

  • Reposition

  • Other options

import matplotlib.pyplot as plt

x = [1,2,3]
y = [4,5,6]

plt.plot(x, y)
plt.show()  # doctest: +SKIP

1.1.7. Exporting plot as an image

import matplotlib.pyplot as plt

x = [1,2,3]
y = [4,5,6]

plt.plot(x, y)

1.1.9. Further Reading