This is one of the most common types of visualization that almost everyone must have encountered. Bars can be drawn horizontally or vertically to represent categorical variables.
Bar charts are frequently used to distinguish objects between distinct collections in order to track variations over time. In most cases, bar charts are very convenient when the changes are large. In order to learn about bar charts, let's assume a pharmacy in Norway keeps track of the amount of Zoloft sold every month. Zoloft is a medicine prescribed to patients suffering from depression. We can use the calendar Python library to keep track of the months of the year (1 to 12) corresponding to January to December:
- Let's import the required libraries:
import numpy as np
import calendar
import matplotlib.pyplot as plt
- Set up the data. Remember, the range stopping parameter is exclusive...