Changeset 695
- Timestamp:
- 09/05/17 16:08:58 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
mds-and-trees/tree-genealogy.py
r694 r695 7 7 from PIL import Image, ImageDraw, ImageFont 8 8 from scipy import stats 9 from matplotlib import colors 9 10 import numpy as np 10 11 … … 23 24 self.h_no_margs = h - 2* h_margin 24 25 25 self.colors = { 26 'white' : {'r':100, 'g':100, 'b':100}, 27 'black' : {'r':0, 'g':0, 'b':0}, 28 'red' : {'r':100, 'g':0, 'b':0}, 29 'green' : {'r':0, 'g':100, 'b':0}, 30 'blue' : {'r':0, 'g':0, 'b':100}, 31 'yellow' : {'r':100, 'g':100, 'b':0}, 32 'magenta' : {'r':100, 'g':0, 'b':100}, 33 'cyan' : {'r':0, 'g':100, 'b':100}, 34 'orange': {'r':100, 'g':50, 'b':0}, 35 'purple': {'r':50, 'g':0, 'b':100} 36 } 26 self.color_converter = colors.ColorConverter() 37 27 38 28 self.settings = { … … 154 144 if isinstance(value, str): 155 145 value = int(value) 156 r = self.colors[self.settings['colors_of_kinds'][value]]['r'] 157 g = self.colors[self.settings['colors_of_kinds'][value]]['g'] 158 b = self.colors[self.settings['colors_of_kinds'][value]]['b'] 146 r, g, b = self.color_converter.to_rgb(self.settings['colors_of_kinds'][value]) 159 147 else: 160 start_color = self.color s[start]161 end_color = self.color s[end]148 start_color = self.color_converter.to_rgb(start) 149 end_color = self.color_converter.to_rgb(end) 162 150 value = 1 - (1-value)**bias 163 r = start_color[ 'r']*(1-value)+end_color['r']*value164 g = start_color[ 'g']*(1-value)+end_color['g']*value165 b = start_color[ 'b']*(1-value)+end_color['b']*value166 return ( r, g,b)151 r = start_color[0]*(1-value)+end_color[0]*value 152 g = start_color[1]*(1-value)+end_color[1]*value 153 b = start_color[2]*(1-value)+end_color[2]*value 154 return (100*r, 100*g, 100*b) 167 155 168 156 def compute_value(self, start, end, value, bias=1):
Note: See TracChangeset
for help on using the changeset viewer.