Untitled

 avatar
unknown
plain_text
a year ago
1.0 kB
7
Indexable
#Από το προηγούμενο code block έχουμε φτιάξει τον πίνακα data που θα χρησιμοποιήοσουμε για να φτίαξουμε το histogram
import matplotlib.pyplot as plt
import numpy as np

names = [data[i][0] for i in [0,4,8]]
years = [data[i][1] for i in range(4)]
numb_of_articles = [data[i][2] for i in range(12)]

bar_colors=['r', 'g', 'b']

bar_width=0.2
index = np.arange(len(years))

plt.bar(index+bar_width-0.2, numb_of_articles[0:4], bar_width, label=names[0], color=bar_colors[0])
plt.bar(index+bar_width, numb_of_articles[4:8], bar_width, label=names[1], color=bar_colors[1]) #Η ασθένεια έχει 0 άρθρα και για τα 4 έτη
plt.bar(index+bar_width+0.2, numb_of_articles[8:12], bar_width, label=names[2], color=bar_colors[2])#Η ασθένει έχει 0 άρθρα και για τα 4 ετη


plt.xlabel('Έτη')
plt.ylabel('# Άρθρων')
plt.title('Άρθρα ανά έτος')
plt.xticks(index + bar_width, years)
plt.legend()
plt.show()
Editor is loading...
Leave a Comment