Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #loop through columns/assignments
- for i in range(2, np.size(grades, axis = 1)):
- #mean grade of each column/assignment
- y2.append(np.mean(grades[:,i]))
- #assignment number
- x2.append(i-1)
- #loop through rows/students
- for j in range(np.size(grades,axis = 0)):
- #computing small random number to display how many students got the grade
- random_val=np.random.uniform(-0.1,0.1,1)
- #assignment plus small random value
- x=i-1+random_val
- #grade plus small random value
- y=grades[j,i]+random_val
- #plot grades as black dots/stars
- plt.plot( x, y,"k*")
- #making plot with average trendline
- plt.plot(x2,y2,'r*', label = "Average grade")
- z = np.polyfit(x2, y2, 1) #plot
- p = np.poly1d(z) #
- plt.plot(x2,p(x2),"r--",label = "Average grade trendline")
- #Plot
- #plt.plot(x,y,"b*", label='hgseljkgh') #plot
- plt.title("Grades per assignment")#title of the graph
- plt.legend(bbox_to_anchor=(1., 1.02, 0., .102), loc = "lower center")
- plt.xlabel("Assignments") #the x-axis label
- plt.ylabel("Grades") #the y-axis label
- plt.xlim() #the limits of the x-axis
- #y-axis limits is set from -4 to 13 to have a clearer view of the grades -3 and 12
- plt.ylim([-4, 13]) #the limits of the y-axis
- plt.grid() #show grid on graph
- #show all plots
- plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement