generated from mwc/lab_scatter
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:
@@ -52,15 +52,15 @@ def draw_axes(data):
|
||||
|
||||
def draw_points(data, color, size):
|
||||
"Draws the scatter plot's points."
|
||||
x_values = get_x_values(data)
|
||||
y_values = get_y_values(data)
|
||||
xmin, xmax = bounds(x_values)
|
||||
ymin, ymax = bounds(y_values)
|
||||
tick = get_tick_values(xmin, xmax)
|
||||
tick = get_tick_values(ymin, ymax)
|
||||
screen_x_position = scale(tick, xmin, xmax, 0, constants.PLOT_WIDTH)
|
||||
screen_y_position = scale(tick, ymin, ymax, 0, constants.PLOT_HEIGHT)
|
||||
draw_point(x, y, color, size)
|
||||
xmin, xmax = bounds(get_x_values(data))
|
||||
ymin, ymax = bounds(get_y_values(data))
|
||||
for point in data:
|
||||
x = point[0]
|
||||
y = point[1]
|
||||
scaled_x = scale(x, xmin, xmax, 0, constants.PLOT_WIDTH)
|
||||
scaled_y = scale(y, ymin, ymax, 0, constants.PLOT_HEIGHT)
|
||||
print(scaled_x, scaled_y)
|
||||
draw_point(scaled_x, scaled_y, color, size)
|
||||
|
||||
with no_delay():
|
||||
data = generate_data(50, 10, 500, 5, 400, 1000)
|
||||
|
||||
Reference in New Issue
Block a user