#Help :)

27 messages · Page 1 of 1 (latest)

valid lightBOT
#

@brave fossil

LuluFire23 Uploaded Some Code

I'm a beginner. Any help is great! I need help making histograms on Juypter notebook or Python application. I can not figure how to fix my numbers to match my data. In the txt file, are the ascending scores . I need that data to create a histogram . For example how many students scored 0's, number for students scored 3's and so forth. I hope this is understandable.

Attachment: cleanData2.txt
0
0
0
0
0
3
3
4
5
5
5
6
6
6
7
8
9
9
9
9
9
10
10
11
11
12
12
12
13
14
15
16
17
18
19
19
19
20
20
21
24
25
26
28
29
29
30
31
32
38
38
38
42
43
44
45
47
48
50
53
53
54
54
56
56
57
60
62
64
76
81
84
fleet kettle
brave fossil
#

f=open('dataClean2.txt', 'r')
print(f)
import matplotlib.pyplot as plt
import os
import numpy as np

a=[]
for x in f:
if x[1] == '':
print(x[10])
b = int(x[0:2])
else:
b =int(x[0:2])
a.append(b)
print(a)

plt.title("Summer 2023 ALEKS Placement Scores")
plt.hist(a)

#

@fleet kettle

fleet kettle
brave fossil
# fleet kettle what's the problem

let me try to explain. The numbers are in a list of scores, I am trying to fix the graph to show how many scored 0's, how many scored 3, how many scored 4,5 , 6 and etc. Do I need to add x= 0,10,20,30,40... and y= 0,10,20,30,40,50.. does it look right? x axis is the scores the 72 students placed and the y axis is how my has 0's, 3's,4's,5's , etc.

fleet kettle
#

look into the docs

#

i mean user error not the library

brave fossil
#

i will try

#

thanks

gilded tartan
brave fossil
fleet kettle
#

um

gilded tartan
fleet kettle
#

yeah

#

i think you're misunderstanding what a histogram is

#

if you want it so that instead of the graph showing ranges in the X axis, it shows each individual value, then use a bar graph

#

but given the range of your data a histogram does make more sense actually.

#

as wang said you can change the bin size to fix it. in your last line of code, have it say
plt.hist(a, bins=len(dict(zip(a,[a.count(i) for i in a])))

this makes it so your plot has as many bins as there are unique items in the array a. i'm in bed rn can't check to make sure this works right

#

@gilded tartan is this a right way to do it?

gilded tartan
#

@brave fossil You just gotta experiment with your bins if you want to keep using a histogram

#

Or use a bar plot