import matplotlib import matplotlib.pyplot as plt import numpy as np import csv imgtype = 'ndvi' uid = 'tszor5vG8vTlW88R8AHmHICNFSo1' labels = ['Good', 'Average', 'Bad'] fileName = 'IndexValues_' + imgtype + '.csv' good = 0 avg = 0 bad = 0 title = imgtype + 'breakdown' with open(fileName) as csv_file: csv_reader = csv.reader(csv_file, delimiter=',') line_count = 0 for row in csv_reader: if line_count == 0: line_count+=1 good = row[0] avg = row[1] bad = row[2] sizes = [good, avg, bad] colors = ['green','yellow','red'] #colors = ['#18A558','#ffea00','#ff4000'] explode = (0.1,0,0) #plt.pie(sizes,explode=explode,labels=labels,colors=colors) plt.pie(sizes,explode=explode,labels=labels,colors=colors,autopct='%1.1f%%',shadow=True,startangle=90) #plt.legend(patches,labels,loc="best") plt.axis('equal') #plt.title(title, loc = 'center') #plt.tight_layout() plt.show() fileName = uid +'/health_pie.png' plt.savefig(fileName)