From b3603aeeb6f499c33b3d4dcb2a59c9f74e76141c Mon Sep 17 00:00:00 2001 From: root Date: Sun, 6 Oct 2024 16:10:03 -0400 Subject: [PATCH] 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. --- scatterplot.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/scatterplot.py b/scatterplot.py index acb666e..1f08a68 100644 --- a/scatterplot.py +++ b/scatterplot.py @@ -60,14 +60,18 @@ def draw_points(data, color, size): y_values = get_y_values(data) ymin, ymax = bounds(y_values) #Find the scaled x-position for the point. + listx = [] for x_value in x_values: scaled_x = scale(x_value, xmin, xmax, 0, constants.PLOT_WIDTH) + listx.append(scaled_x) #Find the scaled y-position for the point. + listy = [] for y_value in y_values: 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) -# 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.