generated from mwc/lab_scatter
Not finished but submitting so professor emma can see
This commit is contained in:
@@ -34,7 +34,18 @@ def draw_scatterplot(data, size=5, color="black"):
|
|||||||
draw_points(data, color, size)
|
draw_points(data, color, size)
|
||||||
|
|
||||||
def draw_axes(data):
|
def draw_axes(data):
|
||||||
"Draws the scatter plot's axes."
|
x_values = get_x_values(data)
|
||||||
|
y_values = get_y_values(data)
|
||||||
|
xmin, xmax = bounds(x_values)
|
||||||
|
ymin, ymax = bounds(y_values)
|
||||||
|
xticks = get_tick_values(xmin, xmax)
|
||||||
|
yticks = get_tick_values(ymin,ymax)
|
||||||
|
for tick in xticks:
|
||||||
|
screen_x_position = scale(tick, xmin, xmax, 0, constants.PLOT_WIDTH)
|
||||||
|
draw_x_tick(screeen_x_position, tick)
|
||||||
|
for tick in yticks:
|
||||||
|
screen_y_position=scale(tick, ymin, ymax, 0, constants.PLOT_WIDTH)
|
||||||
|
draw_y_tick(screen_x_position, tick)
|
||||||
|
|
||||||
def draw_points(data, color, size):
|
def draw_points(data, color, size):
|
||||||
"Draws the scatter plot's points."
|
"Draws the scatter plot's points."
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ def minimum(data):
|
|||||||
|
|
||||||
def bounds(data):
|
def bounds(data):
|
||||||
"Returns a list of the smallest and largest numbers in data"
|
"Returns a list of the smallest and largest numbers in data"
|
||||||
return [minimum(data),maximum(data)]
|
return [minimum(data), maximum(data)]
|
||||||
|
|
||||||
def clamp(value, low, high):
|
def clamp(value, low, high):
|
||||||
"""Clamps a value to a range from low to high.
|
"""Clamps a value to a range from low to high.
|
||||||
|
|||||||
Reference in New Issue
Block a user