Matplotlib: Difference between revisions

From David's Wiki
No edit summary
No edit summary
Line 31: Line 31:
plt.rc('figure', titlesize=BIGGER_SIZE)  # fontsize of the figure title
plt.rc('figure', titlesize=BIGGER_SIZE)  # fontsize of the figure title
</syntaxhighlight>
</syntaxhighlight>
==Animations==
* [https://towardsdatascience.com/animations-with-matplotlib-d96375c5442c Animations with Matplotlib]

Revision as of 15:13, 27 December 2019

Matplotlib is used for making plots in Python

Installation

pip install matplotlib

Usage

Usually you import as follows

import matplotlib.pyplot as plt

Saving a plot

plt.savefig("my_figure.png", dpi=450)

Fonts

Reference

SMALL_SIZE = 8
MEDIUM_SIZE = 10
BIGGER_SIZE = 12

plt.rc('font', size=SMALL_SIZE)          # controls default text sizes
plt.rc('axes', titlesize=SMALL_SIZE)     # fontsize of the axes title
plt.rc('axes', labelsize=MEDIUM_SIZE)    # fontsize of the x and y labels
plt.rc('xtick', labelsize=SMALL_SIZE)    # fontsize of the tick labels
plt.rc('ytick', labelsize=SMALL_SIZE)    # fontsize of the tick labels
plt.rc('legend', fontsize=SMALL_SIZE)    # legend fontsize
plt.rc('figure', titlesize=BIGGER_SIZE)  # fontsize of the figure title

Animations