Commit d528b51a authored by Roshan Rabinarayan's avatar Roshan Rabinarayan

added bar graph

parent c63643b9
No preview for this file type
......@@ -14,6 +14,7 @@ from django.shortcuts import redirect
from .models import result as results
from .models import cribs as crib
from .models import Permission
import collections
from django.db import connection, transaction
import numpy as np
import math
......@@ -159,14 +160,27 @@ def instructor(request):
allStudents.append(student['studentId'])
std=np.std(allMarks)
mean=np.mean(allMarks)
ax.hist(allMarks,allStudents)
html_graph = mpld3.fig_to_html(fig)
data =allMarks
c = collections.Counter(data)
c = sorted(c.items())
months_num = [i[0] for i in c]
freq = [i[1] for i in c]
plt.barh(months_num, freq)
plt.title("Score V/S N.O of Students")
plt.xlabel("N.O of Students")
plt.ylabel("Scores")
ax.set_xticks(range(1,len(allMarks)+1))
#ax.set_xticklabels(months)
html_graph = mpld3.fig_to_html(fig)
fig1, ax1 = plt.subplots()
mu = mean
variance = np.std(allMarks)
sigma = math.sqrt(variance)
x = np.linspace(mu - 3*sigma, mu + 3*sigma, 100)
ax1.plot(x, stats.norm.pdf(x, mu, sigma))
ax1.set_title('Normal Distribution for Scores to Students')
ax1.set_xlabel('Score')
ax1.set_ylabel('PDF')
html_graph1 = mpld3.fig_to_html(fig1)
return render(request, 'instructor.html',{"graph": html_graph, "graph1": html_graph, "graph2": html_graph1,'quiz_id':q_id,'cribs':cribbs})
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment