From 76ab4b547faf2d55408bcd02b6c39090b8ec4af6 Mon Sep 17 00:00:00 2001 From: kated Date: Wed, 18 Mar 2026 11:11:43 -0400 Subject: [PATCH] wrote all of the functions in transform.py to make a scatter plot. --- transform.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/transform.py b/transform.py index ce93916..12e2ab1 100644 --- a/transform.py +++ b/transform.py @@ -28,7 +28,7 @@ def bounds(data): "Returns a list of the smallest and largest numbers in data" lowest = minimum(data) highest = maximum(data) - boundary = [minimum, maximum] + boundary = [lowest, highest] return boundary def clamp(value, low, high): @@ -51,13 +51,14 @@ def ratio(value, start, end): numerator = value - start denominator = end - start ratio = numerator / denominator - final_ratio = clamp(ratio, 0.0, 1.0) - return final_ratio + r = clamp(ratio, 0.0, 1.0) + return r def scale(value, domain_min, domain_max, range_min, range_max): "Given a value within a domain, returns the scaled equivalent within range." - ratio_d = ratio(value, domain_min, domain_max) - ratio_r = ratio(value, range_min, range_max) + r = ratio(value, domain_min, domain_max) + scaled_value = range_min + r * (range_max - range_min) + return scaled_value def get_x_values(points): "Returns the first value for each point in points." @@ -71,6 +72,6 @@ def get_y_values(points): "Returns the second value for each point in points." y_list = [] for i in points: - y_value = i[0] + y_value = i[1] y_list.append(y_value) return y_list