yS=[0], yE=[-(np.sin(theta_total1) * 150 * T1 / (T1 + T2))], xL=[-50 - 0.5 * (np.cos(theta_total1) * 150 * T1 / (T1 + T2))], yL=[-50 - 0.5 * (np.sin(theta_total1) * 150 * T1 / (T1 + T2))], name=["T_1"])) T2_source = ColumnDataSource( dict(xS=[B], xE=[B + (np.cos(theta_total2) * 150 * T2 / (T1 + T2))], yS=[H], yE=[H + (np.sin(theta_total2) * 150 * T2 / (T1 + T2))], xL=[+25 + B + 0.5 * (np.cos(theta_total2) * 150 * T2 / (T1 + T2))], yL=[-25 + H + 0.5 * (np.sin(theta_total2) * 150 * T2 / (T1 + T2))], name=["T_2"])) #Labels and arrows for annotations & cable tensions B_dist = Arrow(end=TeeHead(line_color="#808080", line_width=1, size=10), start=TeeHead(line_color="#808080", line_width=1, size=10), x_start='xS', y_start='yS', x_end='xE', y_end='yE', line_width=1, line_color="#808080", source=B_dist_source) B_dist_label = LatexLabelSet(x='xL', y='yL', text='text', source=B_dist_source) H_dist = Arrow(end=TeeHead(line_color="#808080", line_width=1, size=10), start=TeeHead(line_color="#808080", line_width=1, size=10), x_start='xS', y_start='yS', x_end='xE',
from bokeh.io import save from bokeh.models import Arrow, NormalHead, OpenHead, TeeHead, VeeHead from bokeh.plotting import figure # Have to specify x/y range as labels aren't included in the plot area solver plot = figure(width=600, height=600, x_range=(0,10), y_range=(0,10), toolbar_location=None) arrow1 = Arrow(x_start=1, y_start=4, x_end=6, y_end=9, line_color='green', line_alpha=0.7, line_dash='8 4', line_width=5, end=OpenHead() ) arrow1.end.line_width=8 arrow2 = Arrow(x_start=2, y_start=3, x_end=7, y_end=8, start=NormalHead(), end=VeeHead() ) arrow2.start.fill_color = 'indigo' arrow2.end.fill_color = 'orange' arrow2.end.size = 50 plot.add_layout(arrow1) plot.add_layout(arrow2) # test arrow body clipping plot.add_layout(Arrow(start=TeeHead(line_width=1), x_start=6, y_start=5, x_end=8, y_end=6, line_width=10)) plot.add_layout(Arrow(start=VeeHead(line_width=1, fill_color="white"), x_start=6, y_start=4, x_end=8, y_end=5, line_width=10)) plot.add_layout(Arrow(start=NormalHead(line_width=1, fill_color="white"), x_start=6, y_start=3, x_end=8, y_end=4, line_width=10)) plot.add_layout(Arrow(start=OpenHead(line_width=1), x_start=6, y_start=2, x_end=8, y_end=3, line_width=10)) save(plot)
def test_arrow(output_file_url, selenium, screenshot): # Have to specify x/y range as labels aren't included in the plot area solver plot = figure(height=HEIGHT, width=WIDTH, x_range=(0, 10), y_range=(0, 10), tools='', toolbar_location="above") arrow1 = Arrow(x_start=1, y_start=4, x_end=6, y_end=9, line_color='green', line_alpha=0.7, line_dash='8 4', line_width=5, end=OpenHead()) arrow1.end.line_width = 8 arrow2 = Arrow(x_start=2, y_start=3, x_end=7, y_end=8, start=NormalHead(), end=VeeHead()) arrow2.start.fill_color = 'indigo' arrow2.end.fill_color = 'orange' arrow2.end.size = 50 plot.add_layout(arrow1) plot.add_layout(arrow2) # test arrow body clipping plot.add_layout( Arrow(start=TeeHead(line_width=1), x_start=6, y_start=5, x_end=8, y_end=6, line_width=10)) plot.add_layout( Arrow(start=VeeHead(line_width=1, fill_color="white"), x_start=6, y_start=4, x_end=8, y_end=5, line_width=10)) plot.add_layout( Arrow(start=NormalHead(line_width=1, fill_color="white"), x_start=6, y_start=3, x_end=8, y_end=4, line_width=10)) plot.add_layout( Arrow(start=OpenHead(line_width=1), x_start=6, y_start=2, x_end=8, y_end=3, line_width=10)) # Save the plot and start the test save(plot) selenium.get(output_file_url) assert has_no_console_errors(selenium) # Take screenshot screenshot.assert_is_valid()
arrow2 = Arrow(x_start=2, y_start=3, x_end=7, y_end=8, start=NormalHead(), end=VeeHead()) arrow2.start.fill_color = 'indigo' arrow2.end.fill_color = 'orange' arrow2.end.size = 50 plot.add_layout(arrow1) plot.add_layout(arrow2) # test arrow body clipping plot.add_layout( Arrow(start=TeeHead(line_width=1), x_start=6, y_start=5, x_end=8, y_end=6, line_width=10)) plot.add_layout( Arrow(start=VeeHead(line_width=1, fill_color="white"), x_start=6, y_start=4, x_end=8, y_end=5, line_width=10)) plot.add_layout( Arrow(start=NormalHead(line_width=1, fill_color="white"), x_start=6,
def trefoil(R=1): p = figure(x_range=(-6 * R, 6 * R), y_range=(-6 * R, 6 * R), frame_width=500, frame_height=500, background_fill_color="yellow", title=Title(text="Radiation Warning Symbol (Trefoil)", align="center", text_font_size="20px"), x_axis_type=None, y_axis_type=None, toolbar_location=None) p.annular_wedge( x=0, y=0, inner_radius=1.5 * R, outer_radius=5 * R, start_angle=[0, 120, 240], end_angle=[60, 180, 300], start_angle_units="deg", end_angle_units="deg", line_color="black", fill_color="magenta", ) p.circle( x=0, y=0, radius=R, line_color="black", fill_color="magenta", ) arc = p.arc(x=0, y=0, radius=5.3 * R, start_angle=[60, 120], end_angle=[120, 180], start_angle_units="deg", end_angle_units="deg", line_color="black") arc.add_decoration(TeeHead(size=10), "start") arc.add_decoration(VeeHead(size=8), "start") arc.add_decoration(TeeHead(size=10), "end") arc.add_decoration(VeeHead(size=8), "end") x1, y1 = 5.5 * R * cos(radians(150)), 5.5 * R * sin(radians(150)) p.text(x=[0, x1], y=[5.3 * R, y1], text=value(f"60{degree}"), text_baseline="bottom", text_align="center") p.segment(x0=[0, R, 1.5 * R, 5 * R], y0=0, x1=[0, R, 1.5 * R, 5 * R], y1=[-4 * R, -2 * R, -3 * R, -4 * R], line_color="black", line_dash=value([3, 3])) s = p.segment(x0=0, y0=[-2 * R, -3 * R, -4 * R], x1=[R, 1.5 * R, 5 * R], y1=[-2 * R, -3 * R, -4 * R], line_color="black") s.add_decoration(TeeHead(size=10), "start") s.add_decoration(VeeHead(size=8), "start") s.add_decoration(TeeHead(size=10), "end") s.add_decoration(VeeHead(size=8), "end") p.text(x=0.5 * R, y=-2 * R, text=value("R"), text_baseline="bottom", text_align="center") p.text(x=0.5 * 1.5 * R, y=-3 * R, text=value(f"1.5{cdot}R"), text_baseline="bottom", text_align="center") p.text(x=0.5 * 5 * R, y=-4 * R, text=value(f"5{cdot}R"), text_baseline="bottom", text_align="center") return p
# Plot plot = figure(title="", tools="", x_range=(0 - 2, 40 + 2), y_range=(-50, 50)) plot.toolbar.logo = None plot.axis.axis_label_text_font_style = "normal" plot.axis.axis_label_text_font_size = "14pt" plot.xaxis.axis_label = "Distance [m]" plot.yaxis.axis_label = "Force [N]" # plot bar and support plot.line([0, 40], [0, 0], line_width=10, color='#3070B3') plot.add_glyph( support_source, ImageURL(url="src", x='x', y='y', w=3.3, h=5, anchor="top_center")) # plot distance dist_a = Arrow(end=TeeHead(line_color="#808080", line_width=1, size=10), start=TeeHead(line_color="#808080", line_width=1, size=10), x_start=0, y_start=-15, x_end=20, y_end=-15, line_width=1, line_color="#808080") dist_a_label = LatexLabelSet(x='x', y='y', text='text', source=ColumnDataSource( dict(x=[9.7], y=[-13.5], text=["a"]))) dist_b_source = ColumnDataSource( dict(xS=[20], xE=[30], yS=[15], yE=[15], xL=[24.7], yL=[16.5], text=["b"])) dist_b = Arrow(end=TeeHead(line_color="#808080", line_width=1, size=10),