def test_ImageURL(): glyph = ImageURL() assert glyph.url == "url" assert glyph.x == "x" assert glyph.y == "y" assert glyph.w == "w" assert glyph.h == "h" assert glyph.angle == 0 assert glyph.dilate == False assert glyph.anchor == Anchor.top_left assert glyph.retry_attempts == 0 assert glyph.retry_timeout == 0 assert glyph.global_alpha == 1.0 yield (check_props, glyph, [ "url", "x", "y", "w", "w_units", "h", "h_units", "angle", "angle_units", "dilate", "anchor", "retry_attempts", "retry_timeout", "global_alpha", ])
def test_ImageURL() -> None: glyph = ImageURL() assert glyph.url is None assert glyph.x == field("x") assert glyph.y == field("y") assert glyph.w is None assert glyph.h is None assert glyph.angle == 0 assert glyph.dilate is False assert glyph.anchor == Anchor.top_left assert glyph.retry_attempts == 0 assert glyph.retry_timeout == 0 assert glyph.global_alpha == 1.0 check_properties_existence(glyph, [ "url", "x", "y", "w", "w_units", "h", "h_units", "angle", "angle_units", "dilate", "anchor", "retry_attempts", "retry_timeout", "global_alpha", ], GLYPH)
def draw(variationID, distortion): """This function generates the optical illusion figure. The function should return a bokeh figure of size 500x500 pixels. :param variationID: select which variation to draw (range: 0 to getNumVariations()-1) :param distortion: the selected distortion (range: 0.0 to 1.0) :return handle to bokeh figure that contains the optical illusion """ # global p # global source #here we only change the content of the data source and the circle updates automatically # display the illusion from image. imgString = staticRsrcFolder + 'standard.png' # N = 5 # source = ColumnDataSource(dict( # imgString = [imgString]*N, # x1 = np.linspace( 0, 150, N), # y1 = np.linspace( 0, 150, N), # w1 = np.linspace( 10, 50, N), # h1 = np.linspace( 10, 50, N), # x2 = np.linspace(-50, 150, N), # y2 = np.linspace( 0, 200, N), # )) # image3 = ImageURL(url=dict(value=url), x=200, y=-100, anchor="bottom_right") p = ImageURL(url=imgString, x=100, y=100) # p = figure(x_range=(0,1), y_range=(0,1)) # p.image_url(url=['pngs/standard.png'], x=0, y=1, w=500, h=500) # source.data = dict(radius=[distortion/2], color=[colors[variationID]]) return p
def add_indep(curr_doc: CurrentDoc, x, y, enum_type, name, angle=0.0): """ Add node independent element to the input plot. :param x: x value of node (double) :param y: y value of node (double) :param enum_type: enum_type of element (double of ElementSupportEnum) :param name: name of element (string) :param angle: angle of the element to the x axis (double) :return: none """ indep = curr_doc.data_sources.ds_indep_elements indep_x = indep.data['x'] indep_y = indep.data['y'] indep_t = indep.data['type'] indep_n = indep.data['name'] indep_s = indep.data['same'] indep_a = indep.data['angle'] ds_img_location = map_enum2images[enum_type] # add entry to ds_plot_independent_elements indep_x.append(x) indep_y.append(y) indep_t.append(enum_type) indep_n.append(name) indep_s.append(False) indep_a.append(angle) # add image glyph to plot and display information p = curr_doc.plot_input image = ImageURL( url=dict(value=curr_doc.data_sources.ds_images.data['url'] [ds_img_location]), x=x + curr_doc.data_sources.ds_images.data['x_mod'][ds_img_location], y=y + curr_doc.data_sources.ds_images.data['y_mod'][ds_img_location], w=curr_doc.data_sources.ds_images.data['w'][ds_img_location], h=curr_doc.data_sources.ds_images.data['h'][ds_img_location], anchor="center") p.add_glyph(curr_doc.data_sources.ds_glyph_images, image, name=name) # change angle of image glyph if non-zero if angle: vis_editEl.change_angle_indep(curr_doc, name, angle=angle, index=len(indep_a) - 1) # notify user that the new object was created curr_doc.div_input.text = "Object " + str(name) + " created at: (" + str( x) + "," + str(y) + ")" # show element info of the added element in element info box if not test case if not curr_doc.plotting_test_case: vis_cbs.cb_show_element_info(0, 0, 0, curr_doc, indep=True)
def test_ImageURL(): glyph = ImageURL() assert glyph.url == "url" assert glyph.x == "x" assert glyph.y == "y" assert glyph.w == "w" assert glyph.h == "h" assert glyph.angle == 0 assert glyph.dilate == False assert glyph.anchor == Anchor.top_left yield check_props, glyph, [ "url", "x", "y", "w", "h", "angle", "dilate", "anchor" ]
def make_plot(): xdr = Range1d(start=0, end=1100) ydr = Range1d(start=0, end=750) p = figure(title=None, x_range=xdr, y_range=ydr, plot_width=1100, plot_height=750, h_symmetry=False, v_symmetry=False, min_border=0, toolbar_location=None) image1 = ImageURL(url="url", x=0, y=0, w=900, h=750, anchor="bottom_left") p.add_glyph(source, image1) p.xgrid.grid_line_color = None p.ygrid.grid_line_color = None return p
def getPriceChart(x_dates, y1, y2, ccy): title = "BTC Trading Prices USD vs " + ccy + ". Source: CryptoCompare" ccypair = "BTC" + ccy p = figure(title=title, x_axis_label='Date', y_axis_label='USD', plot_width=1000, plot_height=500, x_axis_type="datetime") p.line(x_dates, y1, line_color="#ffaa0c", line_width=2, legend=ccypair) p.line(x_dates, y2, line_color="white", line_width=2, legend="BTCUSD") p = formatChart(p) source = ColumnDataSource( dict(url=['ccc-logo.png'], x=[x_dates[0]], y=[y1[0]])) image = ImageURL(url="url", x="x", y="y", w=100, h=100, anchor="center") p.add_glyph(source, image) return p
line_width=2)), ("gear", Gear(x="x", y="y", module=0.1, teeth=8, angle=0, shaft_size=0.02, fill_color="#FDF6E3", line_color="#D95F02")), ("image_url", ImageURL( x="x", y="y", w=0.4, h=0.4, url=dict( value="http://bokeh.pydata.org/en/latest/_static/images/logo.png" ), anchor="center")), ("line", Line(x="x", y="y", line_color="#F46D43")), ("multi_line", MultiLine(xs="xs", ys="ys", line_color="#8073AC", line_width=2)), ("oval", Oval(x="x", y="y", width=screen(15), height=screen(25), angle=-0.7, fill_color="#1D91C0")), ("patch", Patch(x="x", y="y", fill_color="#A6CEE3")),
def index(): df, last_update = db.get_grid_data_db() df['jpeg'] = 'static/images/' + df['jpeg'] max_sent = abs(df['avg_sent']).max() df['avg_sent'] = df['avg_sent'] / max_sent cands = db.get_candidates() xdr = Range1d(start=-0, end=df['user_count'].max() + 1000) ydr = Range1d(start=-1.2, end=1.2) source = ColumnDataSource(df) p = figure(plot_height=600, plot_width=800, x_range=xdr, y_range=ydr, toolbar_location=None) #p = figure(sizing_mode="scale_both", x_range=xdr, y_range=ydr, toolbar_location=None) p.circle(x="user_count", y="avg_sent", size=50, source=source, alpha=.05) image = ImageURL(url="jpeg", x="user_count", y="avg_sent", w=None, h=None, anchor="center", global_alpha=.75) p.add_glyph(source, image) p.add_tools( HoverTool(tooltips=[ ("Candidate", "@fullname"), ("Sentiment", "@avg_sent"), ("#Tweeters", "@user_count"), ])) p.toolbar.active_drag = None p.sizing_mode = 'scale_width' xaxis = LinearAxis() p.xaxis.fixed_location = 0 p.xaxis.axis_line_width = 2 p.xaxis.axis_label = 'Number of Tweeters' p.xaxis.axis_label_text_font_style = 'bold' p.xaxis.axis_label_text_font_size = '12pt' p.xaxis.major_label_text_font_style = 'bold' p.xaxis.major_label_text_font_size = '12pt' label = Label(x=df['user_count'].max() / 2, y=-.2, text='Number of Tweeters', level='glyph', render_mode='canvas', text_font_style='bold', text_font_size='12pt') yaxis = LinearAxis() p.yaxis.axis_line_width = 2 p.yaxis.axis_label = 'Sentiment' p.yaxis.axis_label_text_font_style = 'bold' p.yaxis.axis_label_text_font_size = '12pt' p.yaxis.major_label_text_font_style = 'bold' p.yaxis.major_label_text_font_size = '12pt' p.add_layout(Grid(dimension=0, ticker=xaxis.ticker)) p.add_layout(Grid(dimension=1, ticker=yaxis.ticker)) p.add_layout(label) js_resources = INLINE.render_js() css_resources = INLINE.render_css() layout = column(p) script, div = components(layout) html = render_template('main.html', plot_script=script, plot_div=div, js_resources=js_resources, css_resources=css_resources, last_update=last_update, cands=cands) return encode_utf8(html)
ym01 = y - 0.1, )) xdr = DataRange1d() ydr = DataRange1d() def screen(value): return dict(value=value, units="screen") glyphs = [ ("annular_wedge", AnnularWedge(x="x", y="y", inner_radius=screen(10), outer_radius=screen(20), start_angle=0.6, end_angle=4.1, fill_color="#8888ee")), ("annulus", Annulus(x="x", y="y", inner_radius=screen(10), outer_radius=screen(20), fill_color="#7FC97F")), ("arc", Arc(x="x", y="y", radius=screen(20), start_angle=0.6, end_angle=4.1, line_color="#BEAED4", line_width=3)), ("bezier", Bezier(x0="x", y0="y", x1="xp02", y1="y", cx0="xp01", cy0="yp01", cx1="xm01", cy1="ym01", line_color="#D95F02", line_width=2)), ("gear", Gear(x="x", y="y", module=0.1, teeth=8, angle=0, shaft_size=0.02, fill_color="#FDF6E3", line_color="D95F02")), ("image_url", ImageURL(x="x", y="y", w=0.4, h=0.4, url=dict(value="http://bokeh.pydata.org/en/latest/_static/bokeh-transparent.png"), anchor="center")), ("line", Line(x="x", y="y", line_color="#F46D43")), ("multi_line", MultiLine(xs="xs", ys="ys", line_color="#8073AC", line_width=2)), ("oval", Oval(x="x", y="y", width=screen(15), height=screen(25), angle=-0.7, fill_color="#1D91C0")), ("patch", Patch(x="x", y="y", fill_color="#A6CEE3")), ("patches", Patches(xs="xs", ys="ys", fill_color="#FB9A99")), ("quad", Quad(left="x", right="xp01", top="y", bottom="ym01", fill_color="#B3DE69")), ("quadratic", Quadratic(x0="x", y0="y", x1="xp02", y1="y", cx="xp01", cy="yp01", line_color="#4DAF4A", line_width=3)), ("ray", Ray(x="x", y="y", length=45, angle=-0.7, line_color="#FB8072", line_width=2)), ("rect", Rect(x="x", y="y", width=screen(10), height=screen(20), angle=-0.7, fill_color="#CAB2D6")), ("segment", Segment(x0="x", y0="y", x1="xm01", y1="ym01", line_color="#F4A582", line_width=3)), ("text", Text(x="x", y="y", text=["hello"])), ("wedge", Wedge(x="x", y="y", radius=screen(15), start_angle=0.6, end_angle=4.1, fill_color="#B3DE69")), ] markers = [
div.text = ws_out.join(" ") console.log(ws_out) """) img_source = ColumnDataSource(dict(url=[load_dir + wc_filename])) xdr = Range1d(start=0, end=600) ydr = Range1d(start=0, end=600) wc_plot = Plot(title=None, x_range=xdr, y_range=ydr, plot_width=500, plot_height=550, min_border=0) image = ImageURL(url=dict(value=load_dir + wc_filename), x=0, y=0, anchor="bottom_left", retry_attempts=3, retry_timeout=1000) wc_plot.add_glyph(img_source, image) text_0 = Paragraph(text="Clustering option:", width=200, height=20) text_set = Div( text="KMeans: Clusters neurons based on their gate values after training.", width=250, height=100) lrp_timedata = get_lrp_timedata(LRP) time = [i for i in range(len(lrp_timedata))] lrptime_source = ColumnDataSource(dict(lrptime=lrp_timedata, time=time)) lrp_plot = figure(title="Network focus per timestep", plot_width=300,
width = 0.55 height = 0.55 circledim = 0.45 #pre stuff (lines + target) plot.line([-100, 100], [0, 0], line_color="grey", line_width=0.5) plot.line([0, 0], [-100, 100], line_color="grey", line_width=0.5) mul = 2 a, b = 10, 8 source = ColumnDataSource(dict(url=["./emo/male-sign.png"] * 1)) image1 = ImageURL(url="url", x=-a, y=0, w=width * mul, h=height * mul, anchor="center", dilate=False) plot.add_glyph(source, image1) source = ColumnDataSource(dict(url=["./emo/female-sign.png"] * 1)) image1 = ImageURL(url="url", x=a, y=0, w=width * mul, h=height * mul, anchor="center", dilate=False) plot.add_glyph(source, image1)
fig_1.circle(x='x0', y='y', source=current_coords, radius=0.06, line_color=c_black, fill_color=c_white) #joint A fig_1.circle(x='x', y='y0', source=current_coords, radius=0.06, line_color=c_black, fill_color=c_white) #joint B fig_1.line(x='x', y='y', source=support_A_locus, line_width=2, line_color=c_blue, line_dash=[10,10] ) #A locus fig_1.line(x='x', y='y', source=support_B_locus, line_width=2, line_color=c_blue, line_dash=[10,10] ) #B locus fig_1.line(x='x', y='y', source=trace_curve, line_width=2, line_color=c_orange) #trace curve displacement_w = Arrow(end=OpenHead(line_color=c_blue, line_width=2), x_start='xS', y_start='yS', x_end='xE', y_end='yE', line_color=c_blue, line_width=2, level='glyph', source=displacement_w_source) fig_1.add_layout(displacement_w) #displacement w displacement_u = Arrow(end=OpenHead(line_color=c_blue, line_width=2), x_start='xS', y_start='yS', x_end='xE', y_end='yE', line_color=c_blue, line_width=2, level='glyph', source=displacement_u_source) fig_1.add_layout(displacement_u) #displacement u displacement_w_label = LabelSet( x='x', y='y', text='text', source=displacement_w_label_source, text_font_size="15pt", level='glyph', text_color=c_blue ) fig_1.add_layout(displacement_w_label) #displacement w label displacement_u_label = LabelSet( x='x', y='y', text='text', source=displacement_u_label_source, text_font_size="15pt", level='glyph', text_color=c_blue ) fig_1.add_layout(displacement_u_label) #displacement u label # -> add support images fig_1.add_glyph(support_A_img_source , ImageURL(url="sp_img", x="x", y="y", w=0.50, h=0.4, anchor="center", angle=3/2*math.pi)) fig_1.add_glyph(support_B_img_source , ImageURL(url="sp_img", x="x", y="y", w=0.50, h=0.4, anchor="center")) # -> plott ICR fig_1.circle(x='x', y='y', source=current_coords, radius=0.05, line_color=c_orange, fill_color=c_orange) #ICR ICR_label=LabelSet( x='x', y='y', text='text', source=ICR_label_source, text_font_size="15pt", level='glyph', text_color=c_orange ) fig_1.add_layout(ICR_label) # -> displacement ratio fig_2.line(x='x', y='y', source=displacement_ratio_w, line_width=22, line_color=c_blue) fig_2.line(x='x', y='y', source=displacement_ratio_u, line_width=22, line_color=c_blue) fig_2.line(x='x', y='y', source=Frame_w, line_width=4, line_color=c_black) fig_2.line(x='x', y='y', source=Frame_u, line_width=4, line_color=c_black) ratio_w_label = LabelSet( x='x', y='y', text='text', source=displacement_ratio_w_label, text_font_size="15pt", level='glyph', text_color=c_black ) fig_2.add_layout(ratio_w_label) ratio_u_label = LabelSet( x='x', y='y', text='text', source=displacement_ratio_u_label, text_font_size="15pt", level='glyph', text_color=c_black )
def update_source(attrname, old, new): gate_value = gate_selections.value if gate_value == "IN - what to add on": gate_value = "input_gate" elif gate_value == "NOT IMPORTANT - what to drop off": gate_value = "forget_gate" elif gate_value == "IMPORTANT - where to focus on": gate_value = "output_gate" x = data[lstm_layer_name][gate_value] text_review, words, word_embeddings = get_rawText_data( rawInput_selections.value, keys_raw, data_raw, testX, embed_mat) #update raw input text_banner.text = text_review text_banner2.text = text_review label_banner.text = "Network decision : POSITIVE" if predicted_tgs[int( rawInput_selections.value)][0] == 0 else "Network decision : NEGATIVE" #update dimension reduction source algorithm = projection_selections.value knn = 5 x_pr, performance_metric = dim_reduction.project(x, algorithm, knn, labels) #update clustering algorithm_cl_neurons = clustering_selections[0].value n_clusters = int(clustering_selections[1].value) if algorithm_cl_neurons == "Internal state clustering (LSTM's outputs)": text_set.text = "Internal state clustering - selected review: Clusters representation of input review at every timestep as learned by the LSTM layer." lstm_hidVal = np.array(lstm_hidden[int(rawInput_selections.value)]) x_pr, performance_metric = dim_reduction.project( np.transpose(lstm_hidVal), algorithm, knn, labels) cluster_labels, colors, _ = clustering.apply_cluster( data=np.transpose(lstm_hidVal), algorithm=algorithm_cl_neurons, n_clusters=n_clusters, review=None, neuronData=None, mode="nn") elif algorithm_cl_neurons == "DBSCAN - all reviews" or algorithm_cl_neurons == "AgglomerativeClustering - all reviews": if algorithm_cl_neurons == "DBSCAN - all reviews": text_set.text = "DBSCAN - all reviews: Clusters neurons based on how related their most activating words are. List of activating words generated from all reviews." elif algorithm_cl_neurons == "AgglomerativeClustering - all reviews": text_set.text = "AgglomerativeClustering - all reviews: Hierarchical clustering of neurons based on how related their most activating words are. List of activating words generated from all reviews." neuronData = similarityMatrix_AllReviews cluster_labels, colors, _ = clustering.apply_cluster( x, algorithm_cl_neurons, n_clusters, review=rawInput_selections.value, neuronData=neuronData, mode="nn") elif algorithm_cl_neurons == "Positive-Negative neuron clustering (LSTM's predictions)": text_set.text = "Positive-Negative neuron clustering: Clusters neurons based on how much they contributed to classifying the review as positive or negative." neuronData = neuron_types cluster_labels, colors, spectr = clustering.apply_cluster( x, algorithm_cl_neurons, n_clusters, review=rawInput_selections.value, neuronData=neuronData, mode="nn") neutral = tuple( int((spectr[0].lstrip('#'))[i:i + 2], 16) for i in (0, 2, 4)) positive = tuple( int((spectr[1].lstrip('#'))[i:i + 2], 16) for i in (0, 2, 4)) negative = tuple( int((spectr[2].lstrip('#'))[i:i + 2], 16) for i in (0, 2, 4)) neu = "<span style='background-color: rgb(" + str( neutral[0]) + "," + str(neutral[1]) + "," + str( neutral[2]) + ")'>Neutral</span>" pos = "<span style='background-color: rgb(" + str( positive[0]) + "," + str(positive[1]) + "," + str( positive[2]) + ")'>Positive</span>" neg = "<span style='background-color: rgb(" + str( negative[0]) + "," + str(negative[1]) + "," + str( negative[2]) + ")'>Negative</span>" text_set.text = "Positive-Negative neuron clustering: Clusters neurons based on how much they contributed to classifying the review as positive or negative:" + neu + " " + pos + " " + neg else: if algorithm_cl_neurons == "KMeans - selected gate": text_set.text = "KMeans: Clusters neurons based on their gate values after training." elif algorithm_cl_neurons == "DBSCAN - selected review": text_set.text = "DBSCAN - selected review: Clusters neurons based on how related their most activating words are. List of activating words generated from selected review." neuronData = similarityMatrix_PerReview cluster_labels, colors, _ = clustering.apply_cluster( x, algorithm_cl_neurons, n_clusters, review=int(rawInput_selections.value), neuronData=neuronData, mode="nn") proj_source.data = dict(x=x_pr[:, 0], y=x_pr[:, 1], z=colors) w2v_labels, w2v_colors, _ = clustering.apply_cluster( np.array(word_embeddings), "KMeans - selected gate", n_clusters, mode="wc") rawInput_source.data = dict(z=w2v_colors, w=words) color_dict = get_wc_colourGroups(rawInput_source) if gate_value == "input_gate": wc_filename, wc_img, wc_words = get_wcloud( LRP, int(rawInput_selections.value), load_dir, color_dict=color_dict, gate="in", text=text_banner.text) elif gate_value == "forget_gate": wc_filename, wc_img, wc_words = get_wcloud( LRP, int(rawInput_selections.value), load_dir, color_dict=color_dict, gate="forget") elif gate_value == "output_gate": wc_filename, wc_img, wc_words = get_wcloud( LRP, int(rawInput_selections.value), load_dir, color_dict=color_dict, gate="out") words_to_be_highlighted = list( set(wc_words).intersection(totalLRP[int( rawInput_selections.value)]['words'])) lrp_source.data['lrp'] = scaler.fit_transform( np.array(totalLRP[int( rawInput_selections.value)]['lrp'].tolist()).reshape(-1, 1)) tap_source.data['wc_words'] = words_to_be_highlighted wc_plot.add_glyph( img_source, ImageURL(url=dict(value=load_dir + wc_filename), x=0, y=0, anchor="bottom_left"))
# for more attributes have a look at the bokeh documentation figure_name = figure(title="Example Figure", x_range=(-1, max_x), y_range=(-0.5, 2.5), height=300, width=400, tools="pan, wheel_zoom, reset") figure_name.toolbar.logo = None # do not display the bokeh logo ### add the support images ### # urls and coordinates are provided by a ColumnDataSource # anchor specifies at which position of the image the x and y coordinates are referring to # width and height could also be set using constants defined in TA_constants.py and imported here in main.py figure_name.add_glyph( cds_support_left, ImageURL(url="sp_img", x='x', y='y', w=0.66, h=0.4, anchor="center")) figure_name.add_glyph( cds_support_right, ImageURL(url="sp_img", x='x', y='y', w=support_width, h=support_height, anchor="center")) ### add arrows to the figure ### # use either Normalheads or Openheads and orange color by default #arrow_glyph = Arrow(end=NormalHead(line_color=c_orange, fill_color=c_orange), x_start='xS', y_start='yS', x_end='xE', y_end='yE', line_color=c_orange, source=cds_arrow) arrow_glyph = Arrow(end=OpenHead(line_color=c_orange), x_start='xS', y_start='yS',
def add_nodedep(curr_doc: CurrentDoc, enum_type, x, y, length=0.0, angle=0.0, dt_t=(1.0, 0.0, 1.0), k=1.0, h=1.0, ei=1.0, ea=1.0, moment=1.0, f=1.0, ll_local=True, ll_x_n=(0.0, 0.0), ll_y_q=(-1.0, -1.0)): """ Add a node dependent element to the ds_plot_nodedep_elements datasource and a corresponding image glyth to the input plot. :param enum_type: type of element to add (double - ElementSupportEnum) :param x: x position of center of the element or node if only dependent on one node (double) :param y: y position of the center of the element or node if only dependent on one node (double) :param length: length of the element (double) :param angle: angle of the element to the x-axis or y-axis (point load) :param dt_t: defines factors of a temperature load Tupel(dT, T, aT) :param k: factor of spring constant (double) :param h: factor of cross section height (double) :param ei: factor of EI of the beam (double) :param ea: factor of EA of the beam (double) :param moment: factor of moment load (double) :param f: fator of point load (double) :param ll_local: whether line load is defined locally or globally (bool) :param ll_x_n: start and end values of the line load in x or normal direction (Tuple) :param ll_y_q: start and end values of the line load in y or shear direction (Tuple) :return: """ # datasource for nodedependent elements nodedep = curr_doc.data_sources.ds_nodedep_elements # bokeh object: input plot p = curr_doc.plot_input name = str(enum_type) + "-" + str(curr_doc.object_id) curr_doc.object_id += 1 # name_node1 and name_node2 already added in vis_cbs.cb_adapt_plot_nodedep() nodedep.data['type'].append(enum_type) nodedep.data['name'].append(name) nodedep.data['x'].append(x) nodedep.data['y'].append(y) nodedep.data['angle'].append(angle) nodedep_l = nodedep.data['length'] nodedep_dt = nodedep.data['dT_T'] nodedep_k = nodedep.data['k'] nodedep_h = nodedep.data['h'] nodedep_ei = nodedep.data['ei'] nodedep_ea = nodedep.data['ea'] nodedep_m = nodedep.data['moment'] nodedep_f = nodedep.data['f'] nodedep_lll = nodedep.data['ll_local'] nodedep_llxn = nodedep.data['ll_x_n'] nodedep_llyq = nodedep.data['ll_y_q'] # append values to all dict entries and adapt with index nodedep_l.append(False) nodedep_dt.append(False) nodedep_k.append(False) nodedep_h.append(False) nodedep_ei.append(False) nodedep_ea.append(False) nodedep_m.append(False) nodedep_f.append(False) nodedep_lll.append(False) nodedep_llxn.append(False) nodedep_llyq.append(False) index = len(nodedep_l) - 1 # settings and image glyphs for spring_support, spring_moment_support, spring if enum_type == eLnum.ElSupEnum.SPRING_SUPPORT.value or enum_type == eLnum.ElSupEnum.SPRING_MOMENT_SUPPORT.value \ or enum_type == eLnum.ElSupEnum.SPRING.value: nodedep_k[index] = k # mapped position in data source for image glyph ds_img_location = map_enum2images[enum_type] # add element to datasource of nodedep image glyph info ds_glyph = curr_doc.data_sources.ds_glyph_springsPointMomentTemp ds_glyph.data['glyph_x'].append( x + curr_doc.data_sources.ds_images.data['x_mod'][ds_img_location] * 1.5) ds_glyph.data['glyph_y'].append( y + curr_doc.data_sources.ds_images.data['y_mod'][ds_img_location] * 1.5) ds_glyph.data['x'].append(x) ds_glyph.data['y'].append(y) ds_glyph.data['name_user'].append(name) ds_glyph.trigger('data', ds_glyph.data, ds_glyph.data) # create image glyph if enum_type == eLnum.ElSupEnum.SPRING.value: nodedep_l[index] = length length += 0.1 # adapt position because of weird displacement through angle x_mod = -angle / 15.7 y_mod = -abs(angle) / 15.7 x_mod = x_mod - length / 2 * math.cos(angle) y_mod = y_mod - length / 2 * math.sin(angle) image = ImageURL( url=dict(value=curr_doc.data_sources.ds_images.data['url'] [ds_img_location]), x=x + x_mod, y=y + y_mod, w=length, h=curr_doc.data_sources.ds_images.data['h'][ds_img_location], anchor="center_left", angle=angle) else: image = ImageURL( url=dict(value=curr_doc.data_sources.ds_images.data['url'] [ds_img_location]), x=x + curr_doc.data_sources.ds_images.data['x_mod'][ds_img_location], y=y + curr_doc.data_sources.ds_images.data['y_mod'][ds_img_location], w=curr_doc.data_sources.ds_images.data['w'][ds_img_location], h=curr_doc.data_sources.ds_images.data['h'][ds_img_location], anchor="center", angle=0.0) # add image glyph to plot p.add_glyph(curr_doc.data_sources.ds_glyph_images, image, name=name) # adapt angle of image glyph at one node if angle given if angle and not enum_type == eLnum.ElSupEnum.SPRING.value: vis_editEl.change_angle_nodedep( curr_doc, name, angle, index=index, index_glyph=len(ds_glyph.data['x']) - 1) # adapt image glyph of moment if it depicts a negative value if k < 0 and enum_type == eLnum.ElSupEnum.SPRING_MOMENT_SUPPORT.value: vis_editEl.draw_moment_negative(curr_doc, name, index, negative=True) # settings and image glyphs for moment, point load, temperature load elif enum_type == eLnum.ElSupEnum.LOAD_POINT.value or enum_type == eLnum.ElSupEnum.LOAD_MOMENT.value \ or enum_type == eLnum.ElSupEnum.LOAD_TEMP.value: ds_glyph = curr_doc.data_sources.ds_glyph_springsPointMomentTemp ds_img_location = map_enum2images[enum_type] # create and add image glyph to plot image = ImageURL( url=dict(value=curr_doc.data_sources.ds_images.data['url'] [ds_img_location]), x=x + curr_doc.data_sources.ds_images.data['x_mod'][ds_img_location], y=y + curr_doc.data_sources.ds_images.data['y_mod'][ds_img_location], w=curr_doc.data_sources.ds_images.data['w'][ds_img_location], h=curr_doc.data_sources.ds_images.data['h'][ds_img_location], anchor="center", angle=0.0) p.add_glyph(curr_doc.data_sources.ds_glyph_images, image, name=name) # adapt ds_nodedep_element and image glyphs based on the input # also adapt glyph position for load_point and load_moment to make both selectable if enum_type == eLnum.ElSupEnum.LOAD_POINT.value: nodedep_f[index] = f ds_glyph.data['glyph_x'].append( x + curr_doc.data_sources.ds_images.data['x_mod'] [ds_img_location] * 1.5) ds_glyph.data['glyph_y'].append( y + curr_doc.data_sources.ds_images.data['y_mod'] [ds_img_location] * 1.5) elif enum_type == eLnum.ElSupEnum.LOAD_MOMENT.value: nodedep_m[index] = moment ds_glyph.data['glyph_x'].append(x + curr_doc.data_sources.ds_images. data['x_mod'][ds_img_location] - 0.1) ds_glyph.data['glyph_y'].append( y + curr_doc.data_sources.ds_images.data['y_mod'][ds_img_location]) # adapt image glyph of moment if it depicts a negative value if moment < 0: vis_editEl.draw_moment_negative(curr_doc, name, index, negative=True) else: nodedep_dt[index] = dt_t ds_glyph.data['glyph_x'].append( x + curr_doc.data_sources.ds_images.data['x_mod'][ds_img_location]) ds_glyph.data['glyph_y'].append( y + curr_doc.data_sources.ds_images.data['y_mod'][ds_img_location]) # add element to datasource of nodedep image glyph info ds_glyph.data['x'].append(x) ds_glyph.data['y'].append(y) ds_glyph.data['name_user'].append(name) ds_glyph.trigger('data', ds_glyph.data, ds_glyph.data) # adapt angle of image glyph at one node if angle given if angle and enum_type == eLnum.ElSupEnum.LOAD_POINT.value: vis_editEl.change_angle_nodedep( curr_doc, name, angle, index=index, index_glyph=len(ds_glyph.data['x']) - 1) # settings and non-image glyphs for beam elif enum_type == eLnum.ElSupEnum.BEAM.value: nodedep_l[index] = length nodedep_h[index] = h nodedep_ei[index] = ei nodedep_ea[index] = ea # create glyph curr_doc.data_sources.ds_glyph_beam.data['x'].append(x) curr_doc.data_sources.ds_glyph_beam.data['y'].append(y) curr_doc.data_sources.ds_glyph_beam.data['width'].append(length) curr_doc.data_sources.ds_glyph_beam.data['angle'].append(angle) curr_doc.data_sources.ds_glyph_beam.data['name_user'].append(name) curr_doc.data_sources.ds_glyph_beam.trigger( 'data', curr_doc.data_sources.ds_glyph_beam.data, curr_doc.data_sources.ds_glyph_beam.data) # settings and non-image glyph for line load else: nodedep_l[index] = length nodedep_lll[index] = ll_local nodedep_llxn[index] = ll_x_n nodedep_llyq[index] = ll_y_q # create glyph and add element to datasource of line load info vis_editEl.draw_lineload(curr_doc, name, load_x_n=nodedep_llxn[index], load_y_q=nodedep_llyq[index], local=nodedep_lll[index], index=index, create_element=True) # notify user that the new object was created curr_doc.div_input.text = "Object " + str(name) + " created." # show element info of the added element in element info box if not a test case if not curr_doc.plotting_test_case: vis_cbs.cb_show_element_info(0, 0, 0, curr_doc, nodedep=True)
def callback(self, fname): self.weights = np.load("Eigenfaces/weights.npy") self.mean_img_col = np.load("Eigenfaces/mean.npy") self.evectors = np.load("Eigenfaces/eigenfaces.npy") self.faces_paths = np.load("Eigenfaces/faces_paths.npy").astype(str) self.faces_paths = np.append(self.faces_paths, "Eigenfaces/static/tmp.jpg") #print(self.faces_paths) img = cv2.imread("Eigenfaces/static/tmp.jpg", 0) # read as a grayscale image img_col = np.array(img, dtype='float64').flatten() # flatten the image img_col -= self.mean_img_col # subract the mean column img_col = np.reshape(img_col, (92 * 112, 1)) # from row vector to col vector #print("shape of img to be classified: " + str(img_col.shape)) #print("shape of evectors: " + str(self.evectors.shape)) S = self.evectors.transpose().dot( img_col) # projecting the normalized probe onto the # Eigenspace, to find out the weights #print("Shape of weights before: " + str(self.weights.shape)) #print("Shape of S: " + str(S.shape)) diff = self.weights - S # finding the min ||W_j - S|| norms = np.linalg.norm(diff, axis=0) closest_face_id = np.argmin( norms) # the id [0..240) of the minerror face to the sample self.weights = np.append(self.weights, S.transpose(), axis=0) # p = figure() #p.image_url(url=["Eigenfaces/static/tmp.jpg"], w=10, h=10, x=0, y=1) #print("before TSNE" + str(self.weights.shape)) tsne = TSNE(n_components=3, random_state=12) new_weights_tsne = tsne.fit_transform(self.weights) #print("after TSNE" + str(new_weights_tsne.shape)) X_data = new_weights_tsne[:, 0] #print("first axis" + str(X_data.shape)) Y_data = new_weights_tsne[:, 1] #print("first axis" + str(Y_data.shape)) Z_data = new_weights_tsne[:, 2] #print("third axis" + str(Z_data.shape)) length = new_weights_tsne.shape[0] color = np.asarray([1 for x in range(length - 1)] + [0 for x in range(length - 1, length)]) extra = np.asarray([0 for x in range(length)]) source = ColumnDataSource(data=dict(x=X_data, y=Y_data, z=Z_data, color=color, extra=extra, imgs=self.faces_paths)) xdr = Range1d(start=0, end=10) ydr = Range1d(start=0, end=10) plot = Plot(title=None, x_range=xdr, y_range=ydr, plot_width=100, plot_height=100, h_symmetry=False, v_symmetry=False, min_border=0, toolbar_location=None) image1 = ImageURL(url="Eigenfaces/static/tmp.jpg", x=0, y=1, w=20, h=20, anchor="top_left") plot.add_glyph(image1) image2 = ImageURL(url="Eigenfaces/static/tmp.jpg", x=0, y=1, w=20, h=20, anchor="top_right") plot.add_glyph(image2) if self.surface is None: self.surface = Surface3d(x="x", y="y", z="z", extra="extra", color="color", imgs="imgs", data_source=source) curdoc().add_root(row(self.surface)) else: self.surface.data_source = source
plot_3D_source = ColumnDataSource(data=dict(x=[], y=[], z=[])) # 3D plot coordinates support_left_source = ColumnDataSource(data=dict(x = [-0.0015], y = [0.05], src = [pinned_support_img], w = [img_w_pinned] , h = [img_h])) # image support left support_right_source = ColumnDataSource(data=dict(x = [L-0.0015], y = [0.05], src = [pinned_support_img], w = [img_w_pinned] , h = [img_h])) # image support right ################################# ## PLOTS ## ################################# # beam deflection plot = figure(x_range=[-0.2*L,1.2*L], y_range=[-L,L],height = 295, width= 600,toolbar_location = None, tools = "") plot.axis.visible = False plot.grid.visible = False plot.outline_line_color = c_gray plot.line(x=[0,L], y=[0,0], line_color = c_gray, line_dash ="4 4") # beam initial position plot.add_glyph(support_left_source,ImageURL(url="src", x='x', y='y', w= 'w', h= 'h', anchor= "top_center")) # beam supports plot.add_glyph(support_right_source,ImageURL(url="src", x='x', y='y', w= 'w', h= 'h', anchor= "top_center")) # beam supports plot.line(x = 'x', y = 'y', source = beam_coordinates_source, color = c_black) plot.line(x = 'x', y = 'y', source = lfa_coordinates_source, color = c_green, line_dash = "dashed") arrow_load = Arrow(start=NormalHead(line_color=c_orange, fill_color = c_orange, fill_alpha = 0.5), end=NormalHead(line_alpha = 0, fill_alpha = 0), x_start='xs', y_start='ye', x_end='xe', y_end='ys', line_alpha = 0, source=load_arrow_source,line_color=c_white) plot.add_layout(arrow_load) # amplitude for every excitation frequency ratio disp_freq = figure(x_range = [0.04, max_r], y_axis_type="log", y_range = [0.00001,100], height = 335, width = 280,toolbar_location = None, tools = "") disp_freq.yaxis.visible = False disp_freq.add_layout(LogAxis(axis_label='Normalized Deflection W(x)⋅E⋅I/(F⋅L³)'), 'right') disp_freq.xaxis.axis_label = "Excitation Frequency Ratio" disp_freq.outline_line_color = c_gray
width=0.2, source=source, color="#718dbf", legend=value("Ditch")) p.x_range.range_padding = 0.1 p.legend.location = "top_left" p.legend.orientation = "horizontal" columns = [ TableColumn(field="area", title="Area"), TableColumn(field="Raised bed", title="Raised bed(mg)"), TableColumn(field="Ditch", title="Ditch(mg)") ] data_table = DataTable(source=source, columns=columns, width=300, height=300) url = "https://www.ces.ncsu.edu/wp-content/uploads/2013/07/DSC_0489.jpg" source = ColumnDataSource(dict(url=[url])) xdr = Range1d(start=0, end=300) ydr = Range1d(start=0, end=300) plot = Plot(title=None, x_range=xdr, y_range=ydr, plot_width=500, plot_height=420, toolbar_location=None) image = ImageURL(url="url", w=300, h=300, anchor="bottom_left") plot.add_glyph(source, image) show(row(column(p, widgetbox(data_table)), plot))
line_width=3)), ("bezier", Bezier(x0="x", y0="y", x1="xp02", y1="y", cx0="xp01", cy0="yp01", cx1="xm01", cy1="ym01", line_color="#D95F02", line_width=2)), ("image_url", ImageURL(x="x", y="y", w=0.4, h=0.4, url=dict(value="https://static.bokeh.org/logos/logo.png"), anchor="center")), ("line", Line(x="x", y="y", line_color="#F46D43")), ("multi_line", MultiLine(xs="xs", ys="ys", line_color="#8073AC", line_width=2)), ("multi_polygons", MultiPolygons(xs="xsss", ys="ysss", line_color="#8073AC", fill_color="#FB9A99", line_width=2)), ("oval", Oval(x="x", y="y", width=screen(15),
plot.line(x='xs', y='ys', source=line_source_carriage, line_width=10, color="#e37222") plot.square(x='x', y='y', size='size', source=mass_source_carriage, color="#e37222") plot.circle(x='x', y='y', source=x_pt_circle, size=20, color="#a2ad00") plot.circle(x='x', y='y', source=y_pt_circle, size=20, color="#a2ad00") plot.add_glyph( support_source_top, ImageURL(url="src", x='x', y='y', w=60, h=60, anchor="top_center")) plot.add_glyph( support_source_bottom, ImageURL(url="src", x='x', y='y', w=60, h=60, anchor="top_center")) plot.add_layout(T1_arrow_glyph) plot.add_layout(T2_arrow_glyph) plot.add_layout(T1_label_glyph) plot.add_layout(T2_label_glyph) plot.add_layout(B_dist) plot.add_layout(B_dist_label) plot.add_layout(H_dist) plot.add_layout(H_dist_label) plot.add_layout(D_dist) plot.add_layout(D_dist_label) # ----------------------------------------------------------------- #
def winLossChatPlot(request, hero_id): # assemble data heroInstance = models.Hero.objects.get(valveID=hero_id) args = ['heroes', str(heroInstance.valveID), 'matchups'] # list of dicts sorted by n_matches keyed on heroID # {'hero_id': 56, 'games_played': 6, 'wins': 6} heroMatchupData = query_opendota_api_route_args(args, sleepTime=0.) TOOLTIPS = [ ('Hero', '@hero'), ('Win, Loss', '($x{int}, $y{int})'), ] TOOLS = 'pan,wheel_zoom,box_zoom,reset' # init scatter plot bokehAx = bp.figure(width=750, sizing_mode='scale_height', tools=TOOLS) sourceDict = { 'url': [], 'x': [], 'y': [], 'hero': [], } # populate the source dict with matchup data for matchupDict in heroMatchupData: heroMatchup = models.Hero.objects.get(valveID=matchupDict['hero_id']) heroIconURL = heroMatchup.get_absolute_image_url heroIconURL = request.build_absolute_uri(heroMatchup.icon.url) nGames = matchupDict['games_played'] nWins = matchupDict['wins'] nLosses = nGames - nWins sourceDict['url'].append(heroIconURL) sourceDict['x'].append(nWins) sourceDict['y'].append(nLosses) sourceDict['hero'].append(heroMatchup.prettyName) # plot it source = ColumnDataSource(sourceDict) # HoverTool doesn't work with ImageURL, so plot transparent glyphs circle_glyph = Circle(x='x', y='y', size=10, line_color='white', fill_color='white', line_alpha=1., fill_alpha=1.) circle_renderer = bokehAx.add_glyph(source, circle_glyph) icon = ImageURL(url='url', x='x', y='y', w=None, h=None, anchor="center") bokehAx.add_glyph(source, icon) # tooltips hover = HoverTool(renderers=[circle_renderer], tooltips=TOOLTIPS) bokehAx.tools.append(hover) # labels etc bokehAx.title.text = '' bokehAx.xaxis.axis_label = 'Wins (professional games)' bokehAx.yaxis.axis_label = 'Losses (professional games)' plotResponse = file_html(bokehAx, CDN, 'winLossChatPlot') return HttpResponse(plotResponse)
available_ICAmaps = ColumnDataSource(data=dict(urls=ICAmap_paths, cID=cID)) ICAmap_to_display = ColumnDataSource(data=dict( x=[0], y=[0], w=[int(width)], h=[int(height)], url=[ICAmap_default_path])) xdr = Range1d(start=-(int(width) / 2), end=(int(width) / 2)) ydr = Range1d(start=-(int(height) / 2), end=(int(height) / 2)) ICAmapFigure = figure(tools=[], title="ICA maps", x_range=xdr, y_range=ydr, width=1200, height=int((int(height) * 9) / 10), x_axis_type=None, y_axis_type=None, toolbar_location=None, title_text_font_size='12pt') ICAmapImg = ImageURL(url="url", x="x", y="y", w="w", h="h", anchor="center") ICAmapFigure.add_glyph(ICAmap_to_display, ICAmapImg) ICAmapFigure.outline_line_color = '#ffffff' # ============================================================================== # ============================================================================== # JAVA SCRIPT INTERACTIVITY update_ts = CustomJS(args=dict(timeseries_to_display=timeseries_to_display, comp_ts=available_timeseries, ffts_to_display=ffts_to_display, comp_fft=available_ffts, ICApaths=available_ICAmaps, ICAmap_to_display=ICAmap_to_display), code="""
lights = temp lights = lights.reset_index(drop=True) # select only main areas (not corridors) lights = lights.loc[lights['AreaN'] > 9] source = ColumnDataSource(lights) # convert lights dataframe to datasource xdr = Range1d(start=0, end=pWidth) ydr = Range1d(start=0, end=pHeight) plot = figure(x_range=xdr, y_range=ydr, logo=None, tools=TOOLS) image1 = ImageURL(url=dict(value=url), x=0, y=0, w=pWidth, h=pHeight, anchor="bottom_left", global_alpha=1) plot.add_glyph(image1) plot.plot_height = int(pHeight / scale) plot.plot_width = int(pWidth / scale) plot.background_fill_color = "#3b4049" plot.grid.grid_line_color = None plot.axis.axis_line_color = None plot.axis.major_tick_line_color = None plot.axis.visible = False # Plot circles for lights plot.circle(x="X", y="Y",
y_range=(0, 1), width=300, height=int(300 * 1.41421)) make_title(p) def url_formatter(fn): return os.path.join(os.path.basename(os.path.dirname(__file__)), "static", fn) url = url_formatter(pdff.current_gif) im_source = ColumnDataSource(dict(url=[url])) image1 = ImageURL(url="url", x=0, y=1, w=1, h=1) p.add_glyph(im_source, image1) p.on_event(Tap, get_coords) p.circle('x_sign', 'y_sign', source=source, color='red') #show(p) p.circle('x_date', 'y_date', source=source, color='blue') #show(p) def page_change(): im_source.data = {'url': [url_formatter(pdff.current_gif)]} set_source(sgnt.locations[pdff.current_page]) make_title(p) def do_next_page(event): pdff.next_page()
plot_main.add_layout(beam_measure_label) # graphics for a cold beam snow_images = ["Normal_Force_Rod/static/images/snowflake01.svg", "Normal_Force_Rod/static/images/snowflake02.svg", "Normal_Force_Rod/static/images/snowflake03.svg"] cds_snow = ColumnDataSource(data=dict(x=np.linspace(xr_start+0.5, xr_end-0.5,num_symbols), y=np.zeros((num_symbols,1)).flatten(), # copy the image list often enough and select the first num_symbols images # this way the symbols will be repeated in order img=(snow_images*ceil(num_symbols/len(snow_images)))[:num_symbols] )) snow_glyphs = plot_main.add_glyph(cds_snow, ImageURL(url='img', x='x', y='y', w=0.66, h=0.4, anchor="center")) snow_glyphs.visible = False snow_glyphs.level = "overlay" # graphics for a hot beam fire_images = ["Normal_Force_Rod/static/images/fire01.svg", "Normal_Force_Rod/static/images/fire02.svg", "Normal_Force_Rod/static/images/fire03.svg"] cds_fire = ColumnDataSource(data=dict(x=np.linspace(xr_start+0.5, xr_end-0.5,num_symbols), y=np.zeros((num_symbols,1)).flatten(), # copy the image list often enough and select the first num_symbols images # this way the symbols will be repeated in order img=(fire_images*ceil(num_symbols/len(fire_images)))[:num_symbols] ))
first = False text_source = ColumnDataSource(dict(text=text, x=x, y=y, angle=text_angle)) glyph = Text(x="x", y="y", text="text", angle="angle", text_align="center", text_baseline="middle") plot.add_glyph(text_source, glyph) def to_base64(png): return "data:image/png;base64," + base64.b64encode(png).decode("utf-8") urls = [ to_base64(icons.get(browser, b"")) for browser in browsers ] x, y = polar_to_cartesian(1.7, start_angles, end_angles) icons_source = ColumnDataSource(dict(urls=urls, x=x, y=y)) glyph = ImageURL(url="urls", x="x", y="y", anchor="center") plot.add_glyph(icons_source, glyph) text = [ "%.02f%%" % value for value in selected.Share ] x, y = polar_to_cartesian(0.7, start_angles, end_angles) text_source = ColumnDataSource(dict(text=text, x=x, y=y)) glyph = Text(x="x", y="y", text="text", text_align="center", text_baseline="middle") plot.add_glyph(text_source, glyph) doc = Document() doc.add_root(plot) if __name__ == "__main__": filename = "donut.html" with open(filename, "w") as f:
def multi_channel_tile_slider(dataset: TileFeaturesDataset): """ View interactively with bokeh the 3 image tiles """ n = 100 a_img_paths, b_img_paths, c_img_paths = _save_tile_images_to_local_path( dataset, n) # the plotting code plots = [] sources = [] pathes = [a_img_paths, b_img_paths, c_img_paths] plot_num = 3 for i in range(plot_num): p = figure(height=300, width=300) img_paths = pathes[i] # print(img_paths) source = ColumnDataSource(data=dict(url=[img_paths[0]] * n, url_orig=img_paths, x=[1] * n, y=[1] * n, w=[1] * n, h=[1] * n)) image = ImageURL(url="url", x="x", y="y", w="w", h="h", anchor="bottom_left") p.add_glyph(source, glyph=image) _disable_all_for_pictures(p) plots.append(p) sources.append(source) update_source_str = """ var data = source{i}.data; url = data['url'] url_orig = data['url_orig'] for (i = 0; i < url_orig.length; i++) { url[i] = url_orig[f-1] } source{i}.change.emit(); """ # the callback callback = CustomJS(args=dict(source0=sources[0], source1=sources[1], source2=sources[2]), code=f""" var f = cb_obj.value; console.log(f) {"".join([update_source_str.replace('{i}', str(i)) for i in range(plot_num)])} """) slider = Slider(start=1, end=n, value=1, step=1, title="example number") slider.js_on_change('value', callback) column_layout = [slider] curr_row = [] for i in range(len(plots)): if i != 0 and i % 3 == 0: print(curr_row) column_layout.append(row(*curr_row.copy())) curr_row = [] else: curr_row.append(plots[i]) if len(curr_row) != 0: column_layout.append(row(*curr_row.copy())) layout = column(*column_layout) show(layout)
x1 = np.linspace( 0, 150, N), y1 = np.linspace( 0, 150, N), w1 = np.linspace( 10, 50, N), h1 = np.linspace( 10, 50, N), x2 = np.linspace(-50, 150, N), y2 = np.linspace( 0, 200, N), )) xdr = Range1d(start=-100, end=200) ydr = Range1d(start=-100, end=200) plot = Plot(x_range=xdr, y_range=ydr) plot.title.text = "ImageURL" plot.toolbar_location = None image1 = ImageURL(url="url", x="x1", y="y1", w="w1", h="h1", anchor="center", global_alpha=0.2) plot.add_glyph(source, image1) image2 = ImageURL(url="url", x="x2", y="y2", w=20, h=20, anchor="top_left") plot.add_glyph(source, image2) image3 = ImageURL(url=dict(value=url), x=200, y=-100, anchor="bottom_right") plot.add_glyph(image3) xaxis = LinearAxis() plot.add_layout(xaxis, 'below') yaxis = LinearAxis() plot.add_layout(yaxis,'left') plot.add_layout(Grid(dimension=0, ticker=xaxis.ticker))
p1.axis.visible = False #p1.grid.visible = False p1.outline_line_width = 2 p1.outline_line_color = "black" p1.title.text_font_size = "13pt" beam1 = p1.line(x='x', y='y', source=beam1, line_width=5, line_color='black') eigenmodes_beam1 = p1.line(x='x', y='y', source=source1, line_width=3, line_color='#3070b3') # TUM color pantone 300 eigenmodes_beam1.visible = True p1.add_glyph( support_src, ImageURL(url="sp2", x=0.0, y=0.35, w=0.08, h=2, anchor="top_center")) p1.add_glyph( support_src, ImageURL(url="sp1", x=1.0, y=0.35, w=0.072, h=1.8, anchor="top_center")) legend1 = LatexLegend(items=[ (legend_texts[0][0], [eigenmodes_beam1]), (legend_texts[0][1], [eigenmodes_beam1]), ], location=(0, 5), label_height=27, border_line_width=2, border_line_color="black", max_label_width=865) p1.add_layout(legend1, 'above')