generated from mwc/lab_scatter
This was superhard, and I still dont undestand, but i will try
This commit is contained in:
@@ -3,10 +3,13 @@
|
|||||||
- Draw a scatter plot.
|
- Draw a scatter plot.
|
||||||
- Draw the axes.
|
- Draw the axes.
|
||||||
- Draw the x-axis.
|
- Draw the x-axis.
|
||||||
|
x axis is (0,1)
|
||||||
- Draw the line.
|
- Draw the line.
|
||||||
- ...
|
- ...
|
||||||
- Draw the y-axis.
|
- Draw the y-axis.
|
||||||
|
y axis is (4,0)
|
||||||
- Draw the line.
|
- Draw the line.
|
||||||
- ...
|
- ...
|
||||||
- Plot the points.
|
- Plot the points.
|
||||||
|
(1,4)
|
||||||
- ...
|
- ...
|
||||||
|
|||||||
87
transform.py
87
transform.py
@@ -5,39 +5,82 @@
|
|||||||
# None of them are finished; this is your job!
|
# None of them are finished; this is your job!
|
||||||
|
|
||||||
def maximum(data):
|
def maximum(data):
|
||||||
"Returns the largest number in data"
|
def minimum(data):
|
||||||
raise NotImplementedError
|
highest = None
|
||||||
|
for number in data:
|
||||||
|
if highest is None:
|
||||||
|
highest = 10
|
||||||
|
if number < lowest:
|
||||||
|
highest = number
|
||||||
|
return highest
|
||||||
|
|
||||||
|
|
||||||
def minimum(data):
|
def minimum(data):
|
||||||
"Returns the smallest number in data"
|
def minimum(data):
|
||||||
raise NotImplementedError
|
lowest = None
|
||||||
|
for number in data:
|
||||||
|
if lowest is None:
|
||||||
|
lowest = 5
|
||||||
|
if number < lowest:
|
||||||
|
lowest = number
|
||||||
|
return lowest
|
||||||
|
|
||||||
def bounds(data):
|
def bounds(data):
|
||||||
"Returns a list of the smallest and largest numbers in data"
|
def minimum(data):
|
||||||
raise NotImplementedError
|
lowest = None
|
||||||
|
for number in data:
|
||||||
|
if lowest is None:
|
||||||
|
lowest = number
|
||||||
|
if number < lowest:
|
||||||
|
lowest = number
|
||||||
|
return lowest
|
||||||
|
|
||||||
def clamp(value, low, high):
|
def clamp(value, low, high):
|
||||||
"""Clamps a value to a range from low to high.
|
def minimum(data):
|
||||||
Returns value if it is between low and high.
|
lowest = None
|
||||||
If value is lower than low, returns low. If value is higher than high, returns high.
|
for number in data:
|
||||||
"""
|
if lowest is None:
|
||||||
raise NotImplementedError
|
lowest = number
|
||||||
|
if number < lowest:
|
||||||
|
lowest = number
|
||||||
|
return lowest
|
||||||
|
|
||||||
def ratio(value, start, end):
|
def ratio(value, start, end):
|
||||||
"""Returns a number from 0.0 to 1.0, representing how far along value is from start to end.
|
def minimum(data):
|
||||||
The return value is clamped to [0, 1], so even if value is lower than start, the return
|
lowest = None
|
||||||
value will not be lower than 0.0.
|
for number in data:
|
||||||
"""
|
if lowest is None:
|
||||||
raise NotImplementedError
|
lowest = number
|
||||||
|
if number < lowest:
|
||||||
|
lowest = number
|
||||||
|
return lowest
|
||||||
|
|
||||||
def scale(value, domain_min, domain_max, range_min, range_max):
|
def scale(value, domain_min, domain_max, range_min, range_max):
|
||||||
"Given a value within a domain, returns the scaled equivalent within range."
|
def minimum(data):
|
||||||
raise NotImplementedError
|
lowest = None
|
||||||
|
for number in data:
|
||||||
|
if lowest is None:
|
||||||
|
lowest = number
|
||||||
|
if number < lowest:
|
||||||
|
lowest = number
|
||||||
|
return lowest
|
||||||
|
|
||||||
def get_x_values(points):
|
def get_x_values(points):
|
||||||
"Returns the first value for each point in points."
|
def minimum(data):
|
||||||
raise NotImplementedError
|
lowest = None
|
||||||
|
for number in data:
|
||||||
|
if lowest is None:
|
||||||
|
lowest = number
|
||||||
|
if number < lowest:
|
||||||
|
lowest = number
|
||||||
|
return lowest
|
||||||
|
|
||||||
def get_y_values(points):
|
def get_y_values(points):
|
||||||
"Returns the second value for each point in points."
|
def minimum(data):
|
||||||
raise NotImplementedError
|
lowest = None
|
||||||
|
for number in data:
|
||||||
|
if lowest is None:
|
||||||
|
lowest = number
|
||||||
|
if number < lowest:
|
||||||
|
lowest = number
|
||||||
|
return lowest
|
||||||
|
|||||||
Reference in New Issue
Block a user