generated from mwc/lab_scatter
	scatterplot.py
This commit is contained in:
		
							
								
								
									
										20
									
								
								transform.py
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								transform.py
									
									
									
									
									
								
							@@ -4,7 +4,6 @@
 | 
			
		||||
# The functions in this module transform data. 
 | 
			
		||||
# None of them are finished; this is your job!
 | 
			
		||||
 | 
			
		||||
import sys
 | 
			
		||||
 | 
			
		||||
def maximum(data):
 | 
			
		||||
    highest = None
 | 
			
		||||
@@ -49,8 +48,8 @@ def clamp(value, low, high):
 | 
			
		||||
        return high
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def ratio(value, start, end):
 | 
			
		||||
    ratio = (value - start)/(end - start)
 | 
			
		||||
def ratio(value, domain_min, domain_max):
 | 
			
		||||
    ratio = (value - domain_min)/(domain_max - domain_min)
 | 
			
		||||
    return clamp(ratio,0,1)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@@ -61,12 +60,15 @@ def scale(value, domain_min, domain_max, range_min, range_max):
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def get_x_values(points):
 | 
			
		||||
    for (x, y) in points:
 | 
			
		||||
        return ([x], )
 | 
			
		||||
    x_values=[]
 | 
			
		||||
    for ([x, y]) in points:
 | 
			
		||||
        x_values.append(x)
 | 
			
		||||
    return x_values
 | 
			
		||||
    
 | 
			
		||||
def get_y_values(points):
 | 
			
		||||
    for (x, y) in points:
 | 
			
		||||
        return ([y], )
 | 
			
		||||
       
 | 
			
		||||
    
 | 
			
		||||
    y_values=[]
 | 
			
		||||
    for ([x, y]) in points:
 | 
			
		||||
        y_values.append(y)
 | 
			
		||||
    return y_values
 | 
			
		||||
  
 | 
			
		||||
        
 | 
			
		||||
		Reference in New Issue
	
	Block a user