ranges for multiflex
This commit is contained in:
@@ -1314,7 +1314,7 @@ def interactive_multiflex(datadf,xparam,yparam,groupby,extratitle='',
|
|||||||
|
|
||||||
|
|
||||||
for nr, gvalue, color in colorlegend:
|
for nr, gvalue, color in colorlegend:
|
||||||
box = BoxAnnotation(bottom=500-20*nr,left=550,top=520-20*nr,
|
box = BoxAnnotation(bottom=400+20*nr,left=550,top=420+20*nr,
|
||||||
right=570,
|
right=570,
|
||||||
bottom_units='screen',
|
bottom_units='screen',
|
||||||
top_units='screen',
|
top_units='screen',
|
||||||
@@ -1323,7 +1323,7 @@ def interactive_multiflex(datadf,xparam,yparam,groupby,extratitle='',
|
|||||||
fill_color=color,
|
fill_color=color,
|
||||||
fill_alpha=1.0,
|
fill_alpha=1.0,
|
||||||
line_color=color)
|
line_color=color)
|
||||||
legendlabel = Label(x=571,y=503-20*nr,x_units='screen',
|
legendlabel = Label(x=571,y=403+20*nr,x_units='screen',
|
||||||
y_units='screen',
|
y_units='screen',
|
||||||
text = "{gvalue:3.0f}".format(gvalue=gvalue),
|
text = "{gvalue:3.0f}".format(gvalue=gvalue),
|
||||||
background_fill_alpha=1.0,
|
background_fill_alpha=1.0,
|
||||||
|
|||||||
@@ -3604,6 +3604,20 @@ def multiflex_view(request,userid=0,
|
|||||||
yerror = groups.std()[yparam]
|
yerror = groups.std()[yparam]
|
||||||
groupsize = groups.count()[xparam]
|
groupsize = groups.count()[xparam]
|
||||||
|
|
||||||
|
mask = groupsize <= max([0.0003*groupsize.sum(),0.2*groupsize.mean()])
|
||||||
|
xvalues.loc[mask] = np.nan
|
||||||
|
yvalues.loc[mask] = np.nan
|
||||||
|
xerror.loc[mask] = np.nan
|
||||||
|
yerror.loc[mask] = np.nan
|
||||||
|
groupsize.loc[mask] = np.nan
|
||||||
|
|
||||||
|
xvalues.dropna(inplace=True)
|
||||||
|
yvalues.dropna(inplace=True)
|
||||||
|
xerror.dropna(inplace=True)
|
||||||
|
yerror.dropna(inplace=True)
|
||||||
|
groupsize.dropna(inplace=True)
|
||||||
|
|
||||||
|
|
||||||
if len(groupsize) == 0:
|
if len(groupsize) == 0:
|
||||||
messages.error(request,'No data in selection')
|
messages.error(request,'No data in selection')
|
||||||
url = reverse(user_multiflex_select)
|
url = reverse(user_multiflex_select)
|
||||||
@@ -3623,10 +3637,13 @@ def multiflex_view(request,userid=0,
|
|||||||
|
|
||||||
if groupby != 'date':
|
if groupby != 'date':
|
||||||
try:
|
try:
|
||||||
df['groupval'] = groups.mean()[groupby],
|
df['groupval'] = groups.mean()[groupby]
|
||||||
|
df['groupval'].loc[mask] = np.nan
|
||||||
|
|
||||||
groupcols = df['groupval']
|
groupcols = df['groupval']
|
||||||
except ValueError:
|
except ValueError:
|
||||||
df['groupval'] = groups.mean()[groupby].fillna(value=0)
|
df['groupval'] = groups.mean()[groupby].fillna(value=0)
|
||||||
|
df['groupval'].loc[mask] = np.nan
|
||||||
groupcols = df['groupval']
|
groupcols = df['groupval']
|
||||||
except KeyError:
|
except KeyError:
|
||||||
messages.error(request,'Data selection error')
|
messages.error(request,'Data selection error')
|
||||||
@@ -3634,7 +3651,11 @@ def multiflex_view(request,userid=0,
|
|||||||
return HttpResponseRedirect(url)
|
return HttpResponseRedirect(url)
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
df['groupval'] = [x.strftime("%Y-%m-%d") for x in groups.min()[groupby]]
|
dates = groups.min()[groupby]
|
||||||
|
dates.loc[mask] = np.nan
|
||||||
|
dates.dropna(inplace=True)
|
||||||
|
df['groupval'] = [x.strftime("%Y-%m-%d") for x in dates]
|
||||||
|
df['groupval'].loc[mask] = np.nan
|
||||||
groupcols = 100.*np.arange(aantal)/float(aantal)
|
groupcols = 100.*np.arange(aantal)/float(aantal)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
df['groupval'] = groups.mean()['days ago'].fillna(value=0)
|
df['groupval'] = groups.mean()['days ago'].fillna(value=0)
|
||||||
@@ -3652,7 +3673,11 @@ def multiflex_view(request,userid=0,
|
|||||||
|
|
||||||
clegendx = np.arange(0,1.2,.2)
|
clegendx = np.arange(0,1.2,.2)
|
||||||
legcolors = range_to_color_hex(clegendx,palette=palette)
|
legcolors = range_to_color_hex(clegendx,palette=palette)
|
||||||
|
if groupby != 'date':
|
||||||
clegendy = df['groupval'].min()+clegendx*(df['groupval'].max()-df['groupval'].min())
|
clegendy = df['groupval'].min()+clegendx*(df['groupval'].max()-df['groupval'].min())
|
||||||
|
else:
|
||||||
|
clegendy = df.index.min()+clegendx*(df.index.max()-df.index.min())
|
||||||
|
print clegendy
|
||||||
|
|
||||||
|
|
||||||
colorlegend = zip(range(6),clegendy,legcolors)
|
colorlegend = zip(range(6),clegendy,legcolors)
|
||||||
|
|||||||
Reference in New Issue
Block a user