Beispiel #1
0
def _create_plot_component():

    # Create a scalar field to contour
    # uses a randomly sampled, non-uniform grid
    xs = uniform(-2*pi, 2*pi, 600)
    xs.sort()
    ys = uniform(-1.5*pi, 1.5*pi, 300)
    ys.sort()
    x, y = meshgrid(xs,ys)
    z = tanh(x*y/6)*cosh(exp(-y**2)*x/3)
    z = x*y

    # mask out a region with nan values
    mask = ((abs(x-5) <= 1) & (abs(y-2) <= 2))
    z[mask] = nan

    # Create a plot data object and give it this data
    pd = ArrayPlotData()
    pd.set_data("imagedata", z)

    # Create a contour polygon plot of the data
    plot = Plot(pd, default_origin="bottom left")
    plot.contour_plot("imagedata",
                      type="poly",
                      poly_cmap=jet,
                      xbounds=x,
                      ybounds=y)

    # Create a contour line plot for the data, too
    plot.contour_plot("imagedata",
                      type="line",
                      xbounds=x,
                      ybounds=y)

    # Tweak some of the plot properties
    plot.title = "My First Contour Plot"
    plot.padding = 50
    plot.bg_color = "white"
    plot.fill_padding = True

    # Attach some tools to the plot
    plot.tools.append(PanTool(plot))
    zoom = ZoomTool(component=plot, tool_mode="box", always_on=False)
    plot.overlays.append(zoom)
    return plot
def _create_plot_component():

    # Create a scalar field to contour
    # uses a randomly sampled, non-uniform grid
    xs = uniform(-2 * pi, 2 * pi, 600)
    xs.sort()
    ys = uniform(-1.5 * pi, 1.5 * pi, 300)
    ys.sort()
    x, y = meshgrid(xs, ys)
    z = tanh(x * y / 6) * cosh(exp(-y**2) * x / 3)
    z = x * y

    # mask out a region with nan values
    mask = ((abs(x - 5) <= 1) & (abs(y - 2) <= 2))
    z[mask] = nan

    # Create a plot data object and give it this data
    pd = ArrayPlotData()
    pd.set_data("imagedata", z)

    # Create a contour polygon plot of the data
    plot = Plot(pd, default_origin="bottom left")
    plot.contour_plot("imagedata",
                      type="poly",
                      poly_cmap=jet,
                      xbounds=x,
                      ybounds=y)

    # Create a contour line plot for the data, too
    plot.contour_plot("imagedata", type="line", xbounds=x, ybounds=y)

    # Tweak some of the plot properties
    plot.title = "My First Contour Plot"
    plot.padding = 50
    plot.bg_color = "white"
    plot.fill_padding = True

    # Attach some tools to the plot
    plot.tools.append(PanTool(plot))
    zoom = ZoomTool(component=plot, tool_mode="box", always_on=False)
    plot.overlays.append(zoom)
    return plot
Beispiel #3
0
def _create_plot_component():

    # Create a scalar field to contour
    xs = linspace(-2 * pi, 2 * pi, 600)
    ys = linspace(-1.5 * pi, 1.5 * pi, 300)
    x, y = meshgrid(xs, ys)
    z = tanh(x * y / 6) * cosh(exp(-y**2) * x / 3)
    z = x * y

    # Create a plot data obect and give it this data
    pd = ArrayPlotData()
    pd.set_data("imagedata", z)

    # Create a contour polygon plot of the data
    plot = Plot(pd, default_origin="top left")
    plot.contour_plot("imagedata",
                      type="poly",
                      poly_cmap=jet,
                      xbounds=(xs[0], xs[-1]),
                      ybounds=(ys[0], ys[-1]))

    # Create a contour line plot for the data, too
    plot.contour_plot("imagedata",
                      type="line",
                      xbounds=(xs[0], xs[-1]),
                      ybounds=(ys[0], ys[-1]))

    # Tweak some of the plot properties
    plot.title = "My First Contour Plot"
    plot.padding = 50
    plot.bg_color = "white"
    plot.fill_padding = True

    # Attach some tools to the plot
    plot.tools.append(PanTool(plot))
    zoom = ZoomTool(component=plot, tool_mode="box", always_on=False)
    plot.overlays.append(zoom)
    return plot
Beispiel #4
0
def _create_plot_component():

    # Create img data to colormap
    fname = "/Users/maye/Data/hirise/PSP_003092_0985/PSP_003092_0985_RED.cal.norm.map.equ.mos.cub"
    hirise = mars.HiRISE(fname)
    win1 = mars.Window(mars.Point(1792*2,5888*2),width=512)
    hirise.read_window(win1)
    hirise.normalize()

    # Create a plot data obect and give it this data
    pd = ArrayPlotData()
    pd.set_data("imagedata", hirise.data)

    # Create the left plot, a colormap and simple contours
    lplot = Plot(pd)
    lplot.img_plot("imagedata",
                   name="cm_plot",
                   # xbounds=x_extents,
                   # ybounds=y_extents,
                   origin='top left',
                   colormap=gmt_drywet)
    # lplot.contour_plot("imagedata",
    #                    type="line",
    #                    # xbounds=x_extents,
    #                    # ybounds=y_extents,
    #                    )

    # Tweak some of the plot properties
    lplot.title = "Colormap and contours"
    lplot.padding = 20
    lplot.bg_color = "white"
    lplot.fill_padding = True

    # Add some tools to the plot
    zoom = ZoomTool(lplot, tool_mode="box", always_on=False)
    lplot.overlays.append(zoom)
    lplot.tools.append(PanTool(lplot, constrain_key="shift"))

    # # Right now, some of the tools are a little invasive, and we need the
    # # actual CMapImage object to give to them
    # cm_plot = lplot.plots["cm_plot"][0]
    # 
    # # Create the colorbar, handing in the appropriate range and colormap
    # colormap = cm_plot.color_mapper
    # colorbar = ColorBar(index_mapper=LinearMapper(range=colormap.range),
    #                     color_mapper=colormap,
    #                     plot=cm_plot,
    #                     orientation='v',
    #                     resizable='v',
    #                     width=30,
    #                     padding=20)
    # colorbar.padding_top = lplot.padding_top
    # colorbar.padding_bottom = lplot.padding_bottom

    # Create the left plot, contours of varying color and width
    rplot = Plot(pd, range2d=lplot.range2d)
    rplot.contour_plot("imagedata",
                       type="line",
                       # xbounds=x_extents,
                       # ybounds=y_extents,
                       bgcolor="black",
                       levels=15,
                       styles="solid",
                       widths=list(linspace(4.0, 0.1, 15)),
                       colors=gmt_drywet)

    # Add some tools to the plot
    zoom = ZoomTool(rplot, tool_mode="box", always_on=False)
    rplot.overlays.append(zoom)
    rplot.tools.append(PanTool(rplot, constrain_key="shift"))

    # Tweak some of the plot properties
    rplot.title = "Varying contour lines"
    rplot.padding = 20
    rplot.bg_color = "white"
    rplot.fill_padding = True

    # Create a container and add our plots
    container = HPlotContainer(padding=40, fill_padding=True,
                               bgcolor = "white", use_backbuffer=True)
    container.add(colorbar)
    container.add(lplot)
    container.add(rplot)
    return container
Beispiel #5
0
def _create_plot_component():

    # Create a scalar field to colormap
    x_extents = (-2 * pi, 2 * pi)
    y_extents = (-1.5 * pi, 1.5 * pi)
    xs = linspace(-2 * pi, 2 * pi, 200)
    ys = linspace(-1.5 * pi, 1.5 * pi, 100)
    x, y = meshgrid(xs, ys)
    zs = sin(log(abs((x+1)**4)+0.05))*cos(y)*1.1*(-y) + \
            sin(((x+1)**2 + y**2)/4)

    # Create a plot data obect and give it this data
    pd = ArrayPlotData()
    pd.set_data("imagedata", zs)

    # Create the left plot, a colormap and simple contours
    lplot = Plot(pd)
    lplot.img_plot("imagedata",
                   name="cm_plot",
                   xbounds=x_extents,
                   ybounds=y_extents,
                   colormap=gmt_drywet)
    lplot.contour_plot("imagedata",
                       type="line",
                       xbounds=x_extents,
                       ybounds=y_extents)

    # Tweak some of the plot properties
    lplot.title = "Colormap and contours"
    lplot.padding = 20
    lplot.bg_color = "white"
    lplot.fill_padding = True

    # Add some tools to the plot
    zoom = ZoomTool(lplot, tool_mode="box", always_on=False)
    lplot.overlays.append(zoom)
    lplot.tools.append(PanTool(lplot, constrain_key="shift"))

    # Right now, some of the tools are a little invasive, and we need the
    # actual CMapImage object to give to them
    cm_plot = lplot.plots["cm_plot"][0]

    # Create the colorbar, handing in the appropriate range and colormap
    colormap = cm_plot.color_mapper
    colorbar = ColorBar(index_mapper=LinearMapper(range=colormap.range),
                        color_mapper=colormap,
                        plot=cm_plot,
                        orientation='v',
                        resizable='v',
                        width=30,
                        padding=20)
    colorbar.padding_top = lplot.padding_top
    colorbar.padding_bottom = lplot.padding_bottom

    # Create the left plot, contours of varying color and width
    rplot = Plot(pd, range2d=lplot.range2d)
    rplot.contour_plot("imagedata",
                       type="line",
                       xbounds=x_extents,
                       ybounds=y_extents,
                       bgcolor="black",
                       levels=15,
                       styles="solid",
                       widths=list(linspace(4.0, 0.1, 15)),
                       colors=gmt_drywet)

    # Add some tools to the plot
    zoom = ZoomTool(rplot, tool_mode="box", always_on=False)
    rplot.overlays.append(zoom)
    rplot.tools.append(PanTool(rplot, constrain_key="shift"))

    # Tweak some of the plot properties
    rplot.title = "Varying contour lines"
    rplot.padding = 20
    rplot.bg_color = "white"
    rplot.fill_padding = True

    # Create a container and add our plots
    container = HPlotContainer(padding=40,
                               fill_padding=True,
                               bgcolor="white",
                               use_backbuffer=True)
    container.add(colorbar)
    container.add(lplot)
    container.add(rplot)
    return container
Beispiel #6
0
def _create_plot_component():

    # Create a scalar field to colormap
    x_extents = (-2*pi, 2*pi)
    y_extents = (-1.5*pi, 1.5*pi)
    xs = linspace(-2*pi, 2*pi, 200)
    ys = linspace(-1.5*pi, 1.5*pi, 100)
    x, y = meshgrid(xs,ys)
    zs = sin(log(abs((x+1)**4)+0.05))*cos(y)*1.1*(-y) + \
            sin(((x+1)**2 + y**2)/4)

    # Create a plot data obect and give it this data
    pd = ArrayPlotData()
    pd.set_data("imagedata", zs)

    # Create the left plot, a colormap and simple contours
    lplot = Plot(pd)
    lplot.img_plot("imagedata",
                   name="cm_plot",
                   xbounds=x_extents,
                   ybounds=y_extents,
                   colormap=gmt_drywet)
    lplot.contour_plot("imagedata",
                       type="line",
                       xbounds=x_extents,
                       ybounds=y_extents)

    # Tweak some of the plot properties
    lplot.title = "Colormap and contours"
    lplot.padding = 20
    lplot.bg_color = "white"
    lplot.fill_padding = True

    # Add some tools to the plot
    zoom = ZoomTool(lplot, tool_mode="box", always_on=False)
    lplot.overlays.append(zoom)
    lplot.tools.append(PanTool(lplot, constrain_key="shift"))

    # Right now, some of the tools are a little invasive, and we need the
    # actual CMapImage object to give to them
    cm_plot = lplot.plots["cm_plot"][0]

    # Create the colorbar, handing in the appropriate range and colormap
    colormap = cm_plot.color_mapper
    colorbar = ColorBar(index_mapper=LinearMapper(range=colormap.range),
                        color_mapper=colormap,
                        plot=cm_plot,
                        orientation='v',
                        resizable='v',
                        width=30,
                        padding=20)
    colorbar.padding_top = lplot.padding_top
    colorbar.padding_bottom = lplot.padding_bottom

    # Create the left plot, contours of varying color and width
    rplot = Plot(pd, range2d=lplot.range2d)
    rplot.contour_plot("imagedata",
                       type="line",
                       xbounds=x_extents,
                       ybounds=y_extents,
                       bgcolor="black",
                       levels=15,
                       styles="solid",
                       widths=list(linspace(4.0, 0.1, 15)),
                       colors=gmt_drywet)

    # Add some tools to the plot
    zoom = ZoomTool(rplot, tool_mode="box", always_on=False)
    rplot.overlays.append(zoom)
    rplot.tools.append(PanTool(rplot, constrain_key="shift"))

    # Tweak some of the plot properties
    rplot.title = "Varying contour lines"
    rplot.padding = 20
    rplot.bg_color = "white"
    rplot.fill_padding = True

    # Create a container and add our plots
    container = HPlotContainer(padding=40, fill_padding=True,
                               bgcolor = "white", use_backbuffer=True)
    container.add(colorbar)
    container.add(lplot)
    container.add(rplot)
    return container
 def __init__(self, *args, **kwargs):
     super(Demo, self).__init__(*args, **kwargs)
     
     from imread import imread
     imarray = imread(find_resource('imageAlignment', '../images/GIRLS-IN-SPACE.jpg',
         '../images/GIRLS-IN-SPACE.jpg', return_path=True))
     
     self.pd = ArrayPlotData(imagedata=imarray)
     #self.pd.x_axis.orientation = "top"
     self.plot = HPlotContainer()
     
     titles = ["I KEEP DANCE", "ING ON MY OWN"]
     
     
     self._load()
     
     i = 0
     for plc in [Plot, Plot]:
         xs = linspace(0, 334*pi, 333)
         ys = linspace(0, 334*pi, 333)
         x, y = meshgrid(xs,ys)
         z = tanh(x*y/6)*cosh(exp(-y**2)*x/3)
         z = x*y
         
         _pd = ArrayPlotData()
         _pd.set_data("drawdata", z)
         _pd.set_data("imagedata", self.pd.get_data('imagedata'))
         
         plc = Plot(_pd,
             title="render_style = hold",
             padding=50, border_visible=True, overlay_border=True)
         
         self.plot.add(plc)
         
         plc.img_plot("imagedata",
             alpha=0.95)
         
         # Create a contour polygon plot of the data
         plc.contour_plot("drawdata",
                           type="poly",
                           poly_cmap=jet,
                           xbounds=(0, 499),
                           ybounds=(0, 582),
                           alpha=0.35)
         
         # Create a contour line plot for the data, too
         plc.contour_plot("drawdata",
                           type="line",
                           xbounds=(0, 499),
                           ybounds=(0, 582),
                           alpha=0.35)
         
         # Create a plot data obect and give it this data
         plc.legend.visible = True
         plc.title = titles[i]
         i += 1
         
         #plc.plot(("index", "y0"), name="j_0", color="red", render_style="hold")
         
         #plc.padding = 50
         #plc.padding_top = 75
         plc.tools.append(PanTool(plc))
         zoom = ZoomTool(component=plc, tool_mode="box", always_on=False)
         plc.overlays.append(zoom)
         
         # Tweak some of the plot properties
         plc.padding = 50
         #zoom = ZoomTool(component=plot1, tool_mode="box", always_on=False)
         #plot1.overlays.append(zoom)
         
         # Attach some tools to the plot
         #attach_tools(plc)
         plc.bg_color = None
         plc.fill_padding = True