def build_renderers(self): """Yield a `GlyphRenderer` for the group of data.""" glyph = Arc(x='x', y='y', radius=1, start_angle='_end_angle', end_angle='_start_angle', line_color='line_color') yield GlyphRenderer(glyph=glyph)
def test_Arc(): glyph = Arc() assert glyph.x == "x" assert glyph.y == "y" assert glyph.radius == None assert glyph.start_angle == "start_angle" assert glyph.end_angle == "end_angle" assert glyph.direction == "clock" yield check_line, glyph yield check_props, glyph, [ "x", "y", "radius", "start_angle", "end_angle", "direction" ], LINE
def add_gauge(radius, max_value, length, direction, color, major_step, minor_step): major_angles, minor_angles = [], [] major_labels, minor_labels = [], [] total_angle = start_angle - end_angle major_angle_step = float(major_step)/max_value*total_angle minor_angle_step = float(minor_step)/max_value*total_angle major_angle = 0 while major_angle <= total_angle: major_angles.append(start_angle - major_angle) major_angle += major_angle_step minor_angle = 0 while minor_angle <= total_angle: minor_angles.append(start_angle - minor_angle) minor_angle += minor_angle_step major_labels = [ major_step*i for i, _ in enumerate(major_angles) ] minor_labels = [ minor_step*i for i, _ in enumerate(minor_angles) ] n = major_step/minor_step minor_angles = [ x for i, x in enumerate(minor_angles) if i % n != 0 ] minor_labels = [ x for i, x in enumerate(minor_labels) if i % n != 0 ] glyph = Arc(x=0, y=0, radius=radius, start_angle=start_angle, end_angle=end_angle, direction="clock", line_color=color, line_width=2) plot.add_glyph(glyph) rotation = 0 if direction == 1 else -pi x, y = zip(*[ polar_to_cartesian(radius, angle) for angle in major_angles ]) angles = [ angle + rotation for angle in major_angles ] source = ColumnDataSource(dict(x=x, y=y, angle=angles)) glyph = Ray(x="x", y="y", length=data(length), angle="angle", line_color=color, line_width=2) plot.add_glyph(source, glyph) x, y = zip(*[ polar_to_cartesian(radius, angle) for angle in minor_angles ]) angles = [ angle + rotation for angle in minor_angles ] source = ColumnDataSource(dict(x=x, y=y, angle=angles)) glyph = Ray(x="x", y="y", length=data(length/2), angle="angle", line_color=color, line_width=1) plot.add_glyph(source, glyph) x, y = zip(*[ polar_to_cartesian(radius+2*length*direction, angle) for angle in major_angles ]) text_angles = [ angle - pi/2 for angle in major_angles ] source = ColumnDataSource(dict(x=x, y=y, angle=text_angles, text=major_labels)) glyph = Text(x="x", y="y", angle="angle", text="text", text_align="center", text_baseline="middle") plot.add_glyph(source, glyph)
def plotjumps(jumps, ninstructions): xs = [0] + jumps[:-1] ys = [0 for _ in jumps] rs = [abs(x1 - x0) / 2 for x0, x1 in zip(xs, jumps)] xs = [x + r for x, r in zip(xs, rs)] colors = [ Plasma256[255 - round(i * 255 / len(jumps))] for i, _ in zip(count(0), jumps) ] source = ColumnDataSource(dict(x=xs, y=ys, r=rs, c=colors)) xdr = DataRange1d(start=0, end=ninstructions + 0.25) ydr = DataRange1d(start=0) plot = Plot(title=None, x_range=xdr, y_range=ydr, plot_width=800, plot_height=800, h_symmetry=False, v_symmetry=False, min_border=0) # , toolbar_location=None) glyph = Arc(x="x", y="y", radius="r", start_angle=0, end_angle=3.10, line_alpha=1, line_color="c") plot.add_glyph(source, glyph) xaxis = LinearAxis() plot.add_layout(xaxis, 'below') yaxis = LinearAxis() plot.add_layout(yaxis, 'left') plot.add_layout(Grid(dimension=0, ticker=xaxis.ticker)) plot.add_layout(Grid(dimension=1, ticker=yaxis.ticker)) curdoc().add_root(plot) show(plot)
def yield_renderers(self): """Use the marker glyphs to display the arcs and beziers. Takes reference points from data loaded at the ColumnDataSource. """ beziers = Bezier(x0='start_x', y0='start_y', x1='end_x', y1='end_y', cx0='cx0', cy0='cy0', cx1='cx1', cy1='cy1', line_alpha='weight', line_color='colors') yield GlyphRenderer(data_source=self.connection_data, glyph=beziers) arcs = Arc(x=0, y=0, radius=1, line_width=10, start_angle='start_angle', end_angle='end_angle', line_color='line_color') yield GlyphRenderer(data_source=self.arcs_data, glyph=arcs) if self.label: text_props = { "text_color": "#000000", "text_font_size": "8pt", "text_align": "left", "text_baseline": "middle" } labels = Text(x='text_x', y='text_y', text='text', angle='angles', **text_props ) yield GlyphRenderer(data_source=self.text_data, glyph=labels)
def test_Arc() -> None: glyph = Arc() assert glyph.x == field("x") assert glyph.y == field("y") assert glyph.radius is None assert glyph.start_angle is None assert glyph.end_angle is None assert glyph.direction == "anticlock" check_line_properties(glyph) check_properties_existence(glyph, [ "x", "y", "radius", "radius_units", "start_angle", "start_angle_units", "end_angle", "end_angle_units", "direction", ], LINE, GLYPH)
def test_Arc(): glyph = Arc() assert glyph.x is None assert glyph.y is None assert glyph.radius is None assert glyph.start_angle is None assert glyph.end_angle is None assert glyph.direction == "anticlock" yield check_line_properties, glyph yield (check_properties_existence, glyph, [ "x", "y", "radius", "radius_units", "start_angle", "start_angle_units", "end_angle", "end_angle_units", "direction", ], LINE, GLYPH)
r = x / 15.0 + 0.3 source = ColumnDataSource(dict(x=x, y=y, r=r)) plot = Plot(title=None, plot_width=300, plot_height=300, h_symmetry=False, v_symmetry=False, min_border=0, toolbar_location=None) glyph = Arc(x="x", y="y", radius="r", start_angle=0.6, end_angle=4.1, line_color="#beaed4", line_width=3) plot.add_glyph(source, glyph) xaxis = LinearAxis() plot.add_layout(xaxis, 'below') yaxis = LinearAxis() plot.add_layout(yaxis, 'left') plot.add_layout(Grid(dimension=0, ticker=xaxis.ticker)) plot.add_layout(Grid(dimension=1, ticker=yaxis.ticker)) curdoc().add_root(plot)
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",
inner_radius='wedge_inner_radius', # For the inner_radius, use the values in the column # called 'wedge_inner_radius' outer_radius='wedge_outer_radius', # Likewise for the outer radius... line_color='white', fill_color='green', start_angle='start_angle', # ...and start and end angles end_angle='end_angle', direction='anticlock') features = plot.add_glyph(source, annular_wedge) # Add all the wedges to the plot # Add track arc = Arc(x=0, y=0, radius=track_mid_radius, start_angle=0, end_angle=2*pi, direction='clock', line_width=2, line_color="black") plot.add_glyph(arc) # Add start tick source = ColumnDataSource(dict(x=[0, 0], y=[track_inner_radius, track_outer_radius])) line = Line(x='x', y='y', line_color="black", line_width=2) plot.add_glyph(source, line) # Add tooltip features_tooltip = [ ("Start base", "@start_location"), ("End base", "@end_location"), ("Type", "@type"),