Common customizations
One nice thing about matplotlib
is that it allows us to tweak every single element of a plot. We will see some of the common customizations that you will always do when working with matplotlib
when performing data analysis.
First, let's generate some data to work on using the following lines of code:
# Generating data x = np.linspace(-np.pi, np.pi, 200) sine, cosine = np.sin(x), np.cos(x)
We will now look into each customization feature in matplotlib
.
Colors
Colors are associated with everything that is plotted in the figures. Matplotlib supports a very robust language for specifying colors that should be familiar to a wide variety of users.
Colornames
The most common way whereby people use colors in matplotlib
is according to initial or name. So, for every element, such as the color of a bar, a line, or a text, you can pass an additional argument with a string that contains the color that you want. If you want your element to be the color blue, you can pass the string b
,...