adding pb
This commit is contained in:
@@ -2109,116 +2109,11 @@ def interactive_histoall(theworkouts, histoparam, includereststrokes,
|
||||
|
||||
data_dict = {"data": histopwr.tolist(),
|
||||
"metric": metricsdicts[histoparam]["verbose_name"]}
|
||||
print(data_dict)
|
||||
|
||||
script, div = get_chart("/histogram", data_dict, debug=False)
|
||||
|
||||
return script, div
|
||||
|
||||
plot = figure(tools=TOOLS, width=900,
|
||||
toolbar_sticky=False,
|
||||
toolbar_location="above"
|
||||
)
|
||||
|
||||
if extratitle:
|
||||
plot.title.text = extratitle
|
||||
|
||||
|
||||
# add watermark
|
||||
watermarkurl = "/static/img/logo7.png"
|
||||
watermarkrange = Range1d(start=0, end=1)
|
||||
watermarkalpha = 0.6
|
||||
watermarkx = 0.99
|
||||
watermarky = 0.01
|
||||
watermarkw = 184
|
||||
watermarkh = 35
|
||||
watermarkanchor = 'bottom_right'
|
||||
plot.extra_y_ranges = {"watermark": watermarkrange}
|
||||
plot.extra_x_ranges = {"watermark": watermarkrange}
|
||||
|
||||
plot.image_url([watermarkurl], watermarkx, watermarky,
|
||||
watermarkw, watermarkh,
|
||||
global_alpha=watermarkalpha,
|
||||
w_units='screen',
|
||||
h_units='screen',
|
||||
anchor=watermarkanchor,
|
||||
dilate=True,
|
||||
x_range_name="watermark",
|
||||
y_range_name="watermark",
|
||||
)
|
||||
|
||||
hist, edges = np.histogram(histopwr, bins=150)
|
||||
|
||||
histsum = np.cumsum(hist)
|
||||
histsum = 100.*histsum/max(histsum)
|
||||
|
||||
hist_norm = 100.*hist/float(hist.sum())
|
||||
|
||||
source = ColumnDataSource(
|
||||
data=dict(
|
||||
left=edges[:-1],
|
||||
right=edges[1:],
|
||||
histsum=histsum,
|
||||
hist_norm=hist_norm,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
# plot.quad(top='hist_norm',bottom=0,left=edges[:-1],right=edges[1:])
|
||||
plot.quad(top='hist_norm', bottom=0, left='left',
|
||||
right='right', source=source)
|
||||
|
||||
plot.xaxis.axis_label = axlabels[histoparam]
|
||||
plot.yaxis.axis_label = "% of strokes"
|
||||
plot.y_range = Range1d(0, 1.05*max(hist_norm))
|
||||
|
||||
hover = plot.select(dict(type=HoverTool))
|
||||
|
||||
hover.tooltips = OrderedDict([
|
||||
(axlabels[histoparam], '@left{int}'),
|
||||
('% of strokes', '@hist_norm'),
|
||||
('Cumulative %', '@histsum{int}'),
|
||||
])
|
||||
|
||||
hover.mode = 'mouse'
|
||||
|
||||
plot.extra_y_ranges["fraction"] = Range1d(start=0, end=105)
|
||||
plot.line('right', 'histsum', source=source, color="red",
|
||||
y_range_name="fraction")
|
||||
plot.add_layout(LinearAxis(y_range_name="fraction",
|
||||
axis_label="Cumulative % of strokes"), 'right')
|
||||
|
||||
#plot.sizing_mode = 'stretch_both'
|
||||
|
||||
annolabel = Label(x=50, y=450, x_units='screen', y_units='screen',
|
||||
text='',
|
||||
background_fill_alpha=0.7,
|
||||
background_fill_color='white',
|
||||
text_color='black',
|
||||
)
|
||||
|
||||
plot.add_layout(annolabel)
|
||||
|
||||
callback = CustomJS(args=dict(
|
||||
annolabel=annolabel,
|
||||
), code="""
|
||||
var annotation = annotation.value
|
||||
annolabel.text = annotation
|
||||
""")
|
||||
|
||||
annotation = TextInput(
|
||||
width=140, title="Type your plot notes here", value="")
|
||||
annotation.js_on_change('value', callback)
|
||||
callback.args["annotation"] = annotation
|
||||
|
||||
mylayout = layoutcolumn([annotation, plot])
|
||||
|
||||
try:
|
||||
script, div = components(mylayout)
|
||||
except ValueError: # pragma: no cover
|
||||
script = ''
|
||||
div = ''
|
||||
|
||||
return [script, div]
|
||||
|
||||
|
||||
def course_map(course):
|
||||
|
||||
Reference in New Issue
Block a user