Drawing the main plots in Matplotlib
Drawing visuals with Matplotlib is easy. All you need is the right input and a correct understanding of the data. The main five visuals that we use in Matplotlib to draw are histograms, boxplots, bar charts, line plots, and scatterplots. Let's introduce them with the following examples.
Summarizing numerical attributes using histograms or boxplots
We already draw histograms using Pandas, which we learned about in the Pandas functions to explore a DataFrame section in the previous chapter. However, the same plot can also be drawn using Matplotlib. The following screenshot shows the best and most common way to import Matplotlib. There are two points here:
- First, you want to use the
plt
alias, as everyone else uses that. - Second, you want to import
matplotlib.pyplot
instead of justmatplotlib
, as everything we will need frommatplotlib
is under.pyplot
.
The second chunk of code in the following screenshot shows how easy...