generated from mwc/lab_scatter
I did this with Chris
This commit is contained in:
parent
03eeda7ce9
commit
1f65f67efc
|
@ -27,7 +27,7 @@ from transform import (
|
||||||
get_y_values,
|
get_y_values,
|
||||||
)
|
)
|
||||||
|
|
||||||
def draw_scatterplot(data, size=5, color="black"):
|
def draw_scatterplot(data, size, color):
|
||||||
"Draws a scatter plot, showing the data"
|
"Draws a scatter plot, showing the data"
|
||||||
prepare_screen()
|
prepare_screen()
|
||||||
draw_axes(data)
|
draw_axes(data)
|
||||||
|
@ -35,6 +35,8 @@ def draw_scatterplot(data, size=5, color="black"):
|
||||||
|
|
||||||
def draw_axes(data):
|
def draw_axes(data):
|
||||||
"Draws the scatter plot's axes."
|
"Draws the scatter plot's axes."
|
||||||
|
|
||||||
|
|
||||||
draw_x_axis()
|
draw_x_axis()
|
||||||
x_values = get_x_values(data)
|
x_values = get_x_values(data)
|
||||||
xmin, xmax = bounds(x_values)
|
xmin, xmax = bounds(x_values)
|
||||||
|
@ -56,11 +58,12 @@ def draw_points(data, color, size):
|
||||||
"Draws the scatter plot's points."
|
"Draws the scatter plot's points."
|
||||||
xmin, xmax = bounds(get_x_values(data))
|
xmin, xmax = bounds(get_x_values(data))
|
||||||
ymin, ymax = bounds(get_y_values(data))
|
ymin, ymax = bounds(get_y_values(data))
|
||||||
|
"""draw_point(100, 100, color="blue", size = 5)"""
|
||||||
for point in data:
|
for point in data:
|
||||||
x = point[0]
|
x = point[0]
|
||||||
y = point[1]
|
y = point[1]
|
||||||
x_scaled = scale(x, xmin, xmax, ymin, ymax)
|
x_scaled = scale(x, xmin, xmax, 0, constants.PLOT_WIDTH)
|
||||||
y_scaled = scale(y, xmin, xmax, ymin, ymax)
|
y_scaled = scale(y, ymin, ymax, 0, constants.PLOT_HEIGHT)
|
||||||
print(f"Printing point onto the screen at ({x_scaled}, {y_scaled})")
|
print(f"Printing point onto the screen at ({x_scaled}, {y_scaled})")
|
||||||
draw_point(x_scaled, y_scaled, color, size)
|
draw_point(x_scaled, y_scaled, color, size)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue