예제 #1
0
def _create_plot_component():

    # Use n_gon to compute center locations for our polygons
    points = n_gon(center=(0,0), r=3, nsides=4)

    # Choose some colors for our polygons
    colors = {3:0xaabbcc,   4:'orange', 5:'yellow', 6:'lightgreen'}

    # Create a PlotData object to store the polygon data
    pd = ArrayPlotData()

    # Create a Polygon Plot to draw the regular polygons
    polyplot = Plot(pd)

    # Store path data for each polygon, and plot
    nsides = 3
    for p in points:
        npoints = n_gon(center=p, r=2, nsides=nsides)
        nxarray, nyarray = transpose(npoints)
        pd.set_data("x" + str(nsides), nxarray)
        pd.set_data("y" + str(nsides), nyarray)
        plot = polyplot.plot(("x"+str(nsides), "y"+str(nsides)), type="polygon",
                             face_color=colors[nsides], hittest_type="poly")[0]

        plot.tools.append(DataspaceMoveTool(plot, drag_button="left"))
        nsides = nsides + 1

    # Tweak some of the plot properties
    polyplot.padding = 50
    polyplot.title = "Polygon Plot"
    polyplot.x_axis.mapper.range.set(low=-10, high=10)
    polyplot.y_axis.mapper.range.set(low=-10, high=10)

    return polyplot
예제 #2
0
    def _space_plot_default(self):
        self.debug_print('_space_plot_default')
        p = Plot(self.plot_data)

        # Plot track underlay
        x_outer, y_outer = np.transpose(n_gon((0, 0), OUTER_DIAMETER / 2, 48))
        x_inner, y_inner = np.transpose(n_gon((0, 0), INNER_DIAMETER / 2, 48))
        self.plot_data['x_outer'] = x_outer
        self.plot_data['y_outer'] = y_outer
        self.plot_data['x_inner'] = x_inner
        self.plot_data['y_inner'] = y_inner
        self.data_to_keep.extend(['x_outer', 'y_outer', 'x_inner', 'y_inner'])
        p.plot(('x_outer', 'y_outer'),
               type='polygon',
               edge_width=1.0,
               edge_color='darkgrey',
               face_color='linen')
        p.plot(('x_inner', 'y_inner'),
               type='polygon',
               edge_width=1.0,
               edge_color='darkgrey',
               face_color='white')

        p.plot(('pause_x', 'pause_y'), **PAUSE_FMT)
        p.plot(('scan_x', 'scan_y'), **SCAN_FMT)
        p.plot(('x', 'y'))
        p.plot(('cl_x', 'cl_y'), **SPIKE_FMT)
        p.title = 'Space'
        p.x_axis.title = 'X (cm)'
        p.y_axis.title = 'Y (cm)'
        p.padding_bottom = 55
        p.range2d.set_bounds((-50, -50), (50, 50))
        return p
예제 #3
0
def _create_plot_component():

    # Use n_gon to compute center locations for our polygons
    points = n_gon(center=(0, 0), r=4, nsides=8)

    # Choose some colors for our polygons
    colors = {
        3: 0xaabbcc,
        4: 'orange',
        5: 'yellow',
        6: 'lightgreen',
        7: 'green',
        8: 'blue',
        9: 'lavender',
        10: 'purple'
    }

    # Create a PlotData object to store the polygon data
    pd = ArrayPlotData()

    # Create a Polygon Plot to draw the regular polygons
    polyplot = Plot(pd)

    # Store path data for each polygon, and plot
    nsides = 3
    for p in points:
        npoints = n_gon(center=p, r=2, nsides=nsides)
        nxarray, nyarray = transpose(npoints)
        pd.set_data("x" + str(nsides), nxarray)
        pd.set_data("y" + str(nsides), nyarray)
        plot = polyplot.plot(("x" + str(nsides), "y" + str(nsides)),
                             type="polygon",
                             face_color=colors[nsides],
                             hittest_type="poly")[0]
        plot.tools.append(DataspaceMoveTool(plot, drag_button="right"))
        nsides = nsides + 1

    # Tweak some of the plot properties
    polyplot.padding = 50
    polyplot.title = "Polygon Plot"

    # Attach some tools to the plot
    polyplot.tools.append(PanTool(polyplot))
    zoom = ZoomTool(polyplot, tool_mode="box", always_on=False)
    polyplot.overlays.append(zoom)

    return polyplot
예제 #4
0
def _create_plot_component():

    # Use n_gon to compute center locations for our polygons
    points = n_gon(center=(0, 0), r=4, nsides=8)

    # Choose some colors for our polygons
    colors = {
        3: 0xAABBCC,
        4: "orange",
        5: "yellow",
        6: "lightgreen",
        7: "green",
        8: "blue",
        9: "lavender",
        10: "purple",
    }

    # Create a PlotData object to store the polygon data
    pd = ArrayPlotData()

    # Create a Polygon Plot to draw the regular polygons
    polyplot = Plot(pd)

    # Store path data for each polygon, and plot
    nsides = 3
    for p in points:
        npoints = n_gon(center=p, r=2, nsides=nsides)
        nxarray, nyarray = transpose(npoints)
        pd.set_data("x" + str(nsides), nxarray)
        pd.set_data("y" + str(nsides), nyarray)
        plot = polyplot.plot(
            ("x" + str(nsides), "y" + str(nsides)), type="polygon", face_color=colors[nsides], hittest_type="poly"
        )[0]
        plot.tools.append(DataspaceMoveTool(plot, drag_button="right"))
        nsides = nsides + 1

    # Tweak some of the plot properties
    polyplot.padding = 50
    polyplot.title = "Polygon Plot"

    # Attach some tools to the plot
    polyplot.tools.append(PanTool(polyplot))
    zoom = ZoomTool(polyplot, tool_mode="box", always_on=False)
    polyplot.overlays.append(zoom)

    return polyplot
예제 #5
0
def _create_plot_component():

    # Use n_gon to compute center locations of the "global" polygons
    points = n_gon(center=(0,0), r=8, nsides=4)

    # Choose some colors for our polygons
    colors = {0:0xaabbcc,   1:'orange', 2:'yellow', 3:'lightgreen'}

    # Create a PlotData object to store the polygon data
    pd = ArrayPlotData()

    # Create a Polygon Plot to draw the regular polygons
    polyplot = Plot(pd)

    # Store path data for each polygon, and plot
    for n, ctr in enumerate(points):

        nsides = 3
        nodes_x = []
        nodes_y = []

        # Use n_gon again to compute center locations of the "local" polygons
        polyg_pnts = n_gon(center=ctr, r=3, nsides=4)

        for p in polyg_pnts:
            npoints = n_gon(center=p, r=2, nsides=nsides)
            nxarray, nyarray = transpose(npoints)
            nodes_x = nodes_x + list(nxarray) + [nan] # Updates list of polygons
            nodes_y = nodes_y + list(nyarray) + [nan] # Updates list of polygons
            nsides = nsides + 1
        pd.set_data("x"+str(n), nodes_x) # The list of 6 local polygons
        pd.set_data("y"+str(n), nodes_y) # The list of 6 local polygons

        plot = polyplot.plot(("x"+str(n), "y"+str(n)), type="polygon",
                             face_color=colors[n], hittest_type="poly")[0]

        plot.tools.append(DataspaceMoveTool(plot, drag_button="left"))

    # Tweak some of the plot properties
    polyplot.padding = 50
    polyplot.title = "Polygon Plot"
    polyplot.x_axis.mapper.range.set(low=-20, high=20)
    polyplot.y_axis.mapper.range.set(low=-20, high=20)

    return polyplot
def _make_pincell_plot(radius, length):
    npoints1 = n_gon(center=(0,0), r=length/(2**0.5), nsides=4, rot_degrees=45)
    npoints2 = n_gon(center=(0,0), r=radius, nsides=100, rot_degrees=45)
    plotdata = ArrayPlotData()
    pincell_plot = Plot(plotdata)
    nxarray1, nyarray1 = transpose(npoints1)
    nxarray2, nyarray2 = transpose(npoints2)
    plotdata.set_data("x" + str(4), nxarray1)
    plotdata.set_data("y" + str(4), nyarray1)
    pincell_plot.plot(("x"+str(4), "y"+str(4)),
                        type="polygon",
                        face_color="lightblue")
                        
    plotdata.set_data("x" + str(100), nxarray2)
    plotdata.set_data("y" + str(100), nyarray2)
    pincell_plot.plot(("x"+str(100), "y"+str(100)),
                        type="polygon",
                        face_color="red")
    pincell_plot.title = "Fuel Pin Cell"
    return pincell_plot
예제 #7
0
    def _update_data(self):
        distr_len = len(self.data)
        plot_data = self.plot_data

        # centers of the squares
        centers = [(i, 0.5) for i in range(1, distr_len + 1)]

        for idx, center in enumerate(centers):
            # draw square with area proportional to probability mass
            r = np.sqrt(self.data[idx] / (2. * np.pi))
            npoints = n_gon(center=center, r=r, nsides=40)
            nxarray, nyarray = np.transpose(npoints)
            # save in dataarray
            plot_data.set_data('x%d' % idx, nxarray)
            plot_data.set_data('y%d' % idx, nyarray)
예제 #8
0
    def _update_data(self):
        distr_len = len(self.data)
        plot_data = self.plot_data

        # centers of the squares
        centers = [(i, 0.5) for i in xrange(1, distr_len + 1)]

        for idx, center in enumerate(centers):
            # draw square with area proportional to probability mass
            r = np.sqrt(self.data[idx] / (2.*np.pi))
            npoints = n_gon(center=center, r=r, nsides=40)
            nxarray, nyarray = np.transpose(npoints)
            # save in dataarray
            plot_data.set_data('x%d' % idx, nxarray)
            plot_data.set_data('y%d' % idx, nyarray)