Libraries & Dataset
A barplot shows the relationship between a numeric and a categoric variable.
Let's load the numpy and matplotlib libraries that are necessary to build a barplot. If you're not familiar with matplotlib yet, it is the most widespread library for dataviz in python, and the gallery has a dedicated section on it.
Then, let's build a small dataset.
Basic barplot
This example shows probably the most basic barplot you can do with python and matplotlib. The bar() function used with the following parameters:
- x : The x coordinates of the bars. (x_pos in the example)
- height : The height(s) of the bars.
Going further
This post explains how to create a basic barplot using matplotlib!
For more examples of how to create or customize your barplots, see the barplot section. You may also be interested in how to custom colors in a barplot.