Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I used the following python codes to plot histogram. I need to sort the xlabel b

ID: 3370387 • Letter: I

Question

I used the following python codes to plot histogram. I need to sort the xlabel by value (from small to large: 0,4,5,6,7.....). What codes should I add to sort the xlabel in order of value? Where should I add the line of codes.

Thanks

import thinkstats2
import thinkplot


dataList = list()
F = open("student-mat.csv", "r")
for line in F:
spLine = line.split(",")
dataList.append(spLine[32])
  
G3hist = thinkstats2.Hist(dataList)
thinkplot.Hist(G3hist)
thinkplot.Show(xlabel='value', ylabel='frequency')

30 0 10 11 12 13 14 15 16 17 18 19 20 4 5678 9 G value

Explanation / Answer

I think you need to put the “sort_values(‘value’)” in your final line of code.

So, the code should now read:

G3hist=thinkstats2.Hist(dataList)

thinkplot.Hist(G3hist)

thinkplot.show(xlabel=‘value’,ylabel=‘frequency’).sort_value(‘value’)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote