import numpy as np import matplotlib.pyplot as plt M = np.loadtxt('ra_data.txt', delimiter=' ') Kj = M[:, 0] #kjonn Kl = M[:, 1] #klassetrinn Timer = M[:, 2] #antall timer skjermbruk per pers antall_gutter = 0 antall_jenter = 0 for n in range(0, len(Kj), 1): if (Kj[n] == 1): antall_gutter = antall_gutter + 1 else: antall_jenter = antall_jenter + 1 labels = 'gutter', 'jenter' sizes = [antall_gutter, antall_jenter] plt.close('all') plt.pie(sizes, labels=labels, autopct='%1.1f%%') plt.rc('font', size=10) plt.axis('equal') plt.savefig('plott_ra_kake.pdf') plt.show()