bar chart with Matplotlib
11,977
import matplotlib.pyplot as plt
import pandas as pd
data = {'2013': {1:25,2:81,3:15}, '2014': {1:28, 2:65, 3:75}, '2015': {1:78,2:91,3:86 }}
df = pd.DataFrame(data)
df.plot(kind='bar')
plt.show()
I like pandas because it takes your data without having to do any manipulation to it and plot it.
Author by
user3430643
Updated on June 09, 2022Comments
-
user3430643 about 2 years
Here is my data structure:
data = {'2013': {1:25,2:81,3:15}, '2014': {1:28, 2:65, 3:75}, '2015': {1:78,2:91,3:86 }}
My x-axis is the number
[1,2,3]
My y-axis is the quantity of each number. For example: In 2013,
1
is x axis while its quantity is25
.Print each individual graph for each year
I would like to graph a bar chart, which uses matplotlib with legend on it.