9951 explained code solutions for 126 technologies

python-matplotlibHow to plot multiple bars on the same chart

In order to plot multiple lines, you simply call bar() method multiple times (another multiple bar charts example):

import matplotlib.pyplot as plt

plt.bar(['a', 'b', 'c'], [3,4,2])
plt.bar(['a', 'b', 'c'], [1,2,1], width=0.4)

plt.show()ctrl + c
import matplotlib.pyplot as plt

loads Matplotlib module to use plotting capabilities


will plot bar chart


change width for second bar chart, so we can see both charts


render chart in a separate window