I made the scatterplot code work.

The coding went well, and I understood exactly what to do in the lab and how the parts came together.
As I progressed in the lab, I was able to learn how to draw the scatterplot on my own, unlike in Checkpoint 1.
I could be able to write a line graph now.
This commit is contained in:
kdang
2025-10-31 09:35:52 -04:00
parent 84ad738903
commit a1f74335f4

View File

@@ -52,15 +52,15 @@ def draw_axes(data):
def draw_points(data, color, size): def draw_points(data, color, size):
"Draws the scatter plot's points." "Draws the scatter plot's points."
x_values = get_x_values(data) xmin, xmax = bounds(get_x_values(data))
y_values = get_y_values(data) ymin, ymax = bounds(get_y_values(data))
xmin, xmax = bounds(x_values) for point in data:
ymin, ymax = bounds(y_values) x = point[0]
tick = get_tick_values(xmin, xmax) y = point[1]
tick = get_tick_values(ymin, ymax) scaled_x = scale(x, xmin, xmax, 0, constants.PLOT_WIDTH)
screen_x_position = scale(tick, xmin, xmax, 0, constants.PLOT_WIDTH) scaled_y = scale(y, ymin, ymax, 0, constants.PLOT_HEIGHT)
screen_y_position = scale(tick, ymin, ymax, 0, constants.PLOT_HEIGHT) print(scaled_x, scaled_y)
draw_point(x, y, color, size) draw_point(scaled_x, scaled_y, color, size)
with no_delay(): with no_delay():
data = generate_data(50, 10, 500, 5, 400, 1000) data = generate_data(50, 10, 500, 5, 400, 1000)