From 447c833fa7517e2f4dd9947e15d851b98cb357eb Mon Sep 17 00:00:00 2001 From: Sander Roosendaal Date: Tue, 11 Jul 2017 11:13:17 +0200 Subject: [PATCH] blue single hue color scheme --- rowers/interactiveplots.py | 25 +++++++++++++++++++------ rowers/views.py | 8 +++++--- 2 files changed, 24 insertions(+), 9 deletions(-) diff --git a/rowers/interactiveplots.py b/rowers/interactiveplots.py index 7c9b1e26..fe428a73 100644 --- a/rowers/interactiveplots.py +++ b/rowers/interactiveplots.py @@ -1,3 +1,4 @@ +import colorsys from rowers.models import Workout, User, Rower, WorkoutForm,RowerForm,GraphImage from rowingdata import rower as rrower from rowingdata import main as rmain @@ -73,8 +74,6 @@ def errorbar(fig, x, y, source=ColumnDataSource(), xerr=False, yerr=False, color='black', point_kwargs={}, error_kwargs={}): - fig.circle(x, y, source=source, name='data',color=color, - **point_kwargs) xvalues = source.data[x] yvalues = source.data[y] @@ -96,7 +95,12 @@ def errorbar(fig, x, y, source=ColumnDataSource(), for px, py, err, color in zip(xvalues, yvalues, xerrvalues, colorvalues): x_err_x.append((px - err, px + err)) x_err_y.append((py, py)) - err_color.append(color) + (r, g, b) = tuple(int(color[i:i+2],16) for i in (1, 3, 5)) + h,s,v = colorsys.rgb_to_hsv(r/255., g/255., b/255.) + v = v*0.8 + r, g, b = colorsys.hsv_to_rgb(h, s, v) + color2 = "#%02x%02x%02x" % (int(255.*r), int(255.*g), int(255*b)) + err_color.append(color2) fig.multi_line(x_err_x, x_err_y, color=err_color, name='xerr', @@ -113,13 +117,22 @@ def errorbar(fig, x, y, source=ColumnDataSource(), for px, py, err, color in zip(xvalues, yvalues, yerrvalues, colorvalues): y_err_x.append((px, px)) y_err_y.append((py - err, py + err)) - err_color.append(color) + (r, g, b) = tuple(int(color[i:i+2],16) for i in (1, 3, 5)) + h,s,v = colorsys.rgb_to_hsv(r/255., g/255., b/255.) + v = v*0.8 + r, g, b = colorsys.hsv_to_rgb(h, s, v) + color2 = "#%02x%02x%02x" % (int(255.*r), int(255.*g), int(255*b)) + err_color.append(color2) fig.multi_line(y_err_x, y_err_y, color=err_color, name='yerr',**error_kwargs) except TypeError: pass - + + fig.circle(x, y, source=source, name='data',color=color, + **point_kwargs) + + def tailwind(bearing,vwind,winddir): """ Calculates head-on head/tailwind in direction of rowing @@ -1292,7 +1305,7 @@ def interactive_multiflex(datadf,xparam,yparam,groupby,extratitle='', xerr=ploterrorbars, yerr=ploterrorbars, point_kwargs={ - 'line_color':"black", + 'line_color':"#969696", 'size':"groupsize", 'fill_color':"color", }, diff --git a/rowers/views.py b/rowers/views.py index 93b5bb77..6527134a 100644 --- a/rowers/views.py +++ b/rowers/views.py @@ -3604,10 +3604,12 @@ def multiflex_view(request,userid=0, if aantal == 1: groupcols = np.array([1.]) + # rgb = [colorsys.hsv_to_rgb(float(x/100.), 1.0, 1.0) for x in groupcols] + rgb = [colorsys.hsv_to_rgb((207-4*x)/360., + 0.06+0.89*x, + 1-0.38*x) for x in groupcols] + groupcols *= 100. - rgb = [colorsys.hsv_to_rgb(float(x/100.), 1.0, 1.0) for x in groupcols] - rgb = [colorsys.hsv_to_rgb(0.5-0.3*float(x/100.), 0.4+0.4*float(x/100.), 1.0) for x in groupcols] -# rgb = [colorsys.hsv_to_rgb(0.1+0.8*float(x/100.), 0.5, 0.5-0.2*float(x/100.)) for x in groupcols] RGB = [(int(255.*r),int(255.*g),int(255.*b)) for (r, g, b) in rgb] colors = ["#%02x%02x%02x" % (r, g, b) for (r, g, b) in RGB] df['color'] = colors