March 2014
Beginner to intermediate
222 pages
4h 7m
English
When comparing several quantities and when changing one variable, we might want a bar chart where we have bars of one color for one quantity value.
We can plot multiple bar charts by playing with the thickness and the positions of the bars as follows:
import numpy as np import matplotlib.pyplot as plt data = [[5., 25., 50., 20.], [4., 23., 51., 17.], [6., 22., 52., 19.]] X = np.arange(4) plt.bar(X + 0.00, data[0], color = 'b', width = 0.25) plt.bar(X + 0.25, data[1], color = 'g', width = 0.25) plt.bar(X + 0.50, data[2], color = 'r', width = 0.25) plt.show()
The preceding script will produce the following graph:
The data variable contains three series of four values. The preceding script will ...
Read now
Unlock full access