I fixed the draw_points function.

I think this lab was challenging, and I'm not sure if I did it the
way we were supposed to, because I had to search how to use multiple
lists the way I wanted to, which was using zip. I tried adding the two
lists but it didn't seem like that would get my what I wanted, and also
it didn't work. I got stuck on getting the points drawn properly for a
while; first, I got a single point, then I was able to get a vertical
line of points, and then I got identical vertical lines of points at
each of the x-values (when I had the y for loop nested inside of the
x for loop).
I think the top-down vs. bottom-up approaches aren't really separate,
but you have to go back and forth between them because the top-down
approach helps to identify some of the pieces you need to work bottom-
up from.
I felt like at the beginning, I thought the program would use some of
the stuff we did in the pipes lab, so that informed my top-down plan.
Another program I thought about writing during this lab was one that
could take a csv file and identify different common elements and group
them and display them, but that has more to do with other tasks I was
doing than this lab probably, but I still think that some of the things
here probably helped me think about breaking that down into smaller
pieces.
This commit is contained in:
root 2024-10-06 16:10:03 -04:00
parent b588253a8b
commit b3603aeeb6
1 changed files with 6 additions and 2 deletions

View File

@ -60,14 +60,18 @@ def draw_points(data, color, size):
y_values = get_y_values(data) y_values = get_y_values(data)
ymin, ymax = bounds(y_values) ymin, ymax = bounds(y_values)
#Find the scaled x-position for the point. #Find the scaled x-position for the point.
listx = []
for x_value in x_values: for x_value in x_values:
scaled_x = scale(x_value, xmin, xmax, 0, constants.PLOT_WIDTH) scaled_x = scale(x_value, xmin, xmax, 0, constants.PLOT_WIDTH)
listx.append(scaled_x)
#Find the scaled y-position for the point. #Find the scaled y-position for the point.
listy = []
for y_value in y_values: for y_value in y_values:
scaled_y = scale(y_value, ymin, ymax, 0, constants.PLOT_WIDTH) scaled_y = scale(y_value, ymin, ymax, 0, constants.PLOT_WIDTH)
listy.append(scaled_y)
#for something in somethings:
for scaled_x, scaled_y in zip(listx, listy):
draw_point(scaled_x, scaled_y, color, size) draw_point(scaled_x, scaled_y, color, size)
# scaled_x = scale(x_values, xmin, xmax, ymin, ymax)
# scaled_y = scale(y_values, xmin, xmax, ymin, ymax)
#Use draw_point(scaled_x, scaled_y, color, size) to draw the point. #Use draw_point(scaled_x, scaled_y, color, size) to draw the point.