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

.bar

will plot bar chart

width=0.4

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

.show()

render chart in a separate window