generated from mwc/lab_scatter
done with scatter
This commit is contained in:
@@ -35,9 +35,39 @@ def draw_scatterplot(data, size=5, color="black"):
|
||||
|
||||
def draw_axes(data):
|
||||
"Draws the scatter plot's axes."
|
||||
|
||||
draw_x_axis()
|
||||
xxx = get_x_values(data)
|
||||
min, max = bounds(xxx)
|
||||
ticks = get_tick_values(min, max)
|
||||
for tick in ticks:
|
||||
screen_x_position = scale(tick, min, max, 0, constants. PLOT_WIDTH)
|
||||
draw_x_tick(screen_x_position,tick)
|
||||
|
||||
|
||||
|
||||
draw_y_axis()
|
||||
yyy = get_y_values(data)
|
||||
min, max = bounds(yyy)
|
||||
ticks = get_tick_values(min, max)
|
||||
for tick in ticks:
|
||||
screen_y_position = scale(tick, min, max, 0, constants. PLOT_WIDTH)
|
||||
draw_y_tick(screen_y_position,tick)
|
||||
|
||||
|
||||
|
||||
|
||||
def draw_points(data, color, size):
|
||||
"Draws the scatter plot's points."
|
||||
xmin,xmax=bounds(get_x_values(data))
|
||||
ymin,ymax=bounds(get_y_values(data))
|
||||
|
||||
for point in data:
|
||||
x = point[0]
|
||||
y = point[1]
|
||||
x_scaled = scale(x, xmin, xmax, 0, constants.PLOT_WIDTH)
|
||||
y_scaled = scale(y, ymin, ymax, 0, constants.PLOT_WIDTH)
|
||||
print(f"Printing point onto screen at ({x_scaled},{y_scaled})")
|
||||
draw_point(x_scaled, y_scaled, color, size)
|
||||
|
||||
with no_delay():
|
||||
data = generate_data(50, 10, 500, 5, 400, 1000)
|
||||
|
||||
Reference in New Issue
Block a user