当前位置: 首页>>代码示例>>Python>>正文


Python ArrayPlotData.set_data方法代码示例

本文整理汇总了Python中enthought.chaco.api.ArrayPlotData.set_data方法的典型用法代码示例。如果您正苦于以下问题:Python ArrayPlotData.set_data方法的具体用法?Python ArrayPlotData.set_data怎么用?Python ArrayPlotData.set_data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在enthought.chaco.api.ArrayPlotData的用法示例。


在下文中一共展示了ArrayPlotData.set_data方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _create_plot_component

# 需要导入模块: from enthought.chaco.api import ArrayPlotData [as 别名]
# 或者: from enthought.chaco.api.ArrayPlotData import set_data [as 别名]
def _create_plot_component():

    # Create some x-y data series to plot
    x = linspace(-2.0, 10.0, 100)
    pd = ArrayPlotData(index = x)
    for i in range(5):
        pd.set_data("y" + str(i), jn(i,x))

    # Create some line plots of some of the data
    plot1 = Plot(pd, padding=50)
    plot1.plot(("index", "y0", "y1", "y2"), name="j_n, n<3", color="red")
    plot1.plot(("index", "y3"), name="j_3", color="blue")

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

    # Add the scrollbar
    hscrollbar = PlotScrollBar(component=plot1, axis="index", resizable="h",
                               height=15)
    plot1.padding_top = 0
    hscrollbar.force_data_update()

    # Create a container and add our plots
    container = VPlotContainer()
    container.add(plot1)
    container.add(hscrollbar)

    return container
开发者ID:brycehendrix,项目名称:chaco,代码行数:32,代码来源:scrollbar.py

示例2: __init__

# 需要导入模块: from enthought.chaco.api import ArrayPlotData [as 别名]
# 或者: from enthought.chaco.api.ArrayPlotData import set_data [as 别名]
    def __init__(self, index, data_series, **kw):
        super(MyPlot, self).__init__(**kw)

        plot_data = ArrayPlotData(index=index)
        plot_data.set_data('data_series', data_series)
        self.plot = Plot(plot_data)
        self.plot.plot(('index', 'data_series'))
开发者ID:brycehendrix,项目名称:chaco,代码行数:9,代码来源:status_overlay.py

示例3: _create_plot_component

# 需要导入模块: from enthought.chaco.api import ArrayPlotData [as 别名]
# 或者: from enthought.chaco.api.ArrayPlotData import set_data [as 别名]
def _create_plot_component():

    # Create some data
    numpts = 5000
    x = sort(random(numpts))
    y = random(numpts)

    # Create a plot data obect and give it this data
    pd = ArrayPlotData()
    pd.set_data("index", x)
    pd.set_data("value", y)

    # Create the plot
    plot = Plot(pd)
    plot.plot(("index", "value"),
              type="scatter",
              marker="circle",
              index_sort="ascending",
              color="orange",
              marker_size=3,
              bgcolor="white")

    # Tweak some of the plot properties
    plot.title = "Scatter Plot"
    plot.line_width = 0.5
    plot.padding = 50

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

    return plot
开发者ID:brycehendrix,项目名称:chaco,代码行数:35,代码来源:scatter.py

示例4: _create_plot_component

# 需要导入模块: from enthought.chaco.api import ArrayPlotData [as 别名]
# 或者: from enthought.chaco.api.ArrayPlotData import set_data [as 别名]
def _create_plot_component():

    # Create some RGBA image data
    image = zeros((200,400,4), dtype=uint8)
    image[:,0:40,0] += 255     # Vertical red stripe
    image[0:25,:,1] += 255     # Horizontal green stripe; also yellow square
    image[-80:,-160:,2] += 255 # Blue square
    image[:,:,3] = 255

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

    # Create the plot
    plot = Plot(pd, default_origin="top left")
    plot.x_axis.orientation = "top"
    img_plot = plot.img_plot("imagedata")[0]

    # Tweak some of the plot properties
    plot.bgcolor = "white"

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

    imgtool = ImageInspectorTool(img_plot)
    img_plot.tools.append(imgtool)
    plot.overlays.append(ImageInspectorOverlay(component=img_plot,
                                               image_inspector=imgtool))
    return plot
开发者ID:brycehendrix,项目名称:chaco,代码行数:33,代码来源:image_plot.py

示例5: _create_plot_component

# 需要导入模块: from enthought.chaco.api import ArrayPlotData [as 别名]
# 或者: from enthought.chaco.api.ArrayPlotData import set_data [as 别名]
def _create_plot_component():

    # Create some x-y data series (with NaNs) to plot
    x = linspace(-5.0, 15.0, 500)
    x[75:125] = nan
    x[200:250] = nan
    x[300:330] = nan
    pd = ArrayPlotData(index = x)
    pd.set_data("value1", jn(0, x))
    pd.set_data("value2", jn(1, x))

    # Create some line and scatter plots of the data
    plot = Plot(pd)
    plot.plot(("index", "value1"), name="j_0(x)", color="red", width=2.0)
    plot.plot(("index", "value2"), type="scatter", marker_size=1,
              name="j_1(x)", color="green")

    # Tweak some of the plot properties
    plot.title = "Plots with NaNs"
    plot.padding = 50
    plot.legend.visible = 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
开发者ID:brycehendrix,项目名称:chaco,代码行数:30,代码来源:nans_plot.py

示例6: __init__

# 需要导入模块: from enthought.chaco.api import ArrayPlotData [as 别名]
# 或者: from enthought.chaco.api.ArrayPlotData import set_data [as 别名]
    def __init__(self, depth, data_series, **kw):
        super(MyPlot, self).__init__(**kw)

        plot_data = ArrayPlotData(index=depth)
        plot_data.set_data('data_series', data_series)
        self.plot = Plot(plot_data, orientation='v', origin='top left')
        self.plot.plot(('index', 'data_series'))
开发者ID:brycehendrix,项目名称:chaco,代码行数:9,代码来源:depth.py

示例7: _create_plot_component

# 需要导入模块: from enthought.chaco.api import ArrayPlotData [as 别名]
# 或者: from enthought.chaco.api.ArrayPlotData import set_data [as 别名]
def _create_plot_component():# Create a scalar field to colormap
    xbounds = (-2*pi, 2*pi, 600)
    ybounds = (-1.5*pi, 1.5*pi, 300)
    xs = linspace(*xbounds)
    ys = linspace(*ybounds)
    x, y = meshgrid(xs,ys)
    z = sin(x)*y

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

    # Create the plot
    plot = Plot(pd)
    img_plot = plot.img_plot("imagedata",
                             xbounds=xbounds[:2],
                             ybounds=ybounds[:2],
                             colormap=jet)[0]

    # Tweak some of the plot properties
    plot.title = "Image Plot with Lasso"
    plot.padding = 50

    lasso_selection = LassoSelection(component=img_plot)
    lasso_selection.on_trait_change(lasso_updated, "disjoint_selections")
    lasso_overlay = LassoOverlay(lasso_selection = lasso_selection, component=img_plot)
    img_plot.tools.append(lasso_selection)
    img_plot.overlays.append(lasso_overlay)
    return plot
开发者ID:brycehendrix,项目名称:chaco,代码行数:31,代码来源:image_lasso.py

示例8: DataChooser

# 需要导入模块: from enthought.chaco.api import ArrayPlotData [as 别名]
# 或者: from enthought.chaco.api.ArrayPlotData import set_data [as 别名]
class DataChooser(HasTraits):

    plot = Instance(Plot)
    data_name = Enum("jn0", "jn1", "jn2")
    traits_view = View(Item('data_name', label="Y data"),
                       Item('plot', editor=ComponentEditor(), show_label=False),
                       width=800, height=600, resizable=True,
                       title="Data Chooser")

    def __init__(self):
        x = linspace(-5, 10, 100)
        self.data = {"jn0": jn(0, x),
                     "jn1": jn(1, x),
                     "jn2": jn(2, x)}

        # Create the data and the PlotData object
        self.plotdata = ArrayPlotData(x=x, y=self.data["jn0"])

        # Create a Plot and associate it with the PlotData
        plot = Plot(self.plotdata)
        # Create a line plot in the Plot
        plot.plot(("x", "y"), type="line", color="blue")
        self.plot = plot

    def _data_name_changed(self, old, new):
        self.plotdata.set_data("y", self.data[self.data_name])
开发者ID:brycehendrix,项目名称:chaco,代码行数:28,代码来源:data_chooser.py

示例9: _create_plot_component

# 需要导入模块: from enthought.chaco.api import ArrayPlotData [as 别名]
# 或者: from enthought.chaco.api.ArrayPlotData import set_data [as 别名]
def _create_plot_component():# Create a scalar field to colormap
    xbounds = (-2*pi, 2*pi, 600)
    ybounds = (-1.5*pi, 1.5*pi, 300)
    xs = linspace(*xbounds)
    ys = linspace(*ybounds)
    x, y = meshgrid(xs,ys)
    z = sin(x)*y

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

    # Create the plot
    plot = Plot(pd)
    img_plot = plot.img_plot("imagedata",
                             xbounds = xbounds[:2],
                             ybounds = ybounds[:2],
                             colormap=jet)[0]

    # Tweak some of the plot properties
    plot.title = "My First Image Plot"
    plot.padding = 50

    # 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)
    imgtool = ImageInspectorTool(img_plot)
    img_plot.tools.append(imgtool)
    overlay = ImageInspectorOverlay(component=img_plot, image_inspector=imgtool,
                                    bgcolor="white", border_visible=True)

    img_plot.overlays.append(overlay)
    return plot
开发者ID:brycehendrix,项目名称:chaco,代码行数:36,代码来源:image_inspector.py

示例10: _create_plot_component

# 需要导入模块: from enthought.chaco.api import ArrayPlotData [as 别名]
# 或者: from enthought.chaco.api.ArrayPlotData import set_data [as 别名]
def _create_plot_component():

    # Create some x-y data series to plot
    x = linspace(-2.0, 10.0, 100)
    pd = ArrayPlotData(index = x)
    for i in range(5):
        pd.set_data("y" + str(i), jn(i,x))

    # Create some line plots of some of the data
    plot1 = Plot(pd, title="Line Plot", padding=50, border_visible=True)
    plot1.legend.visible = True
    plot1.plot(("index", "y0", "y1", "y2"), name="j_n, n<3", color="red")
    plot1.plot(("index", "y3"), name="j_3", color="blue")

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

    # Create a second scatter plot of one of the datasets, linking its
    # range to the first plot
    plot2 = Plot(pd, range2d=plot1.range2d, title="Scatter plot", padding=50,
                 border_visible=True)
    plot2.plot(('index', 'y3'), type="scatter", color="blue", marker="circle")

    # Create a container and add our plots
    container = HPlotContainer()
    container.add(plot1)
    container.add(plot2)

    return container
开发者ID:brycehendrix,项目名称:chaco,代码行数:33,代码来源:line_plot1.py

示例11: _create_plot_component

# 需要导入模块: from enthought.chaco.api import ArrayPlotData [as 别名]
# 或者: from enthought.chaco.api.ArrayPlotData import set_data [as 别名]
def _create_plot_component():
    # Create a GridContainer to hold all of our plots
    container = GridContainer(padding=20, fill_padding=True,
                              bgcolor="lightgray", use_backbuffer=True,
                              shape=(3,3), spacing=(12,12))

    # Create the initial series of data
    x = linspace(-5, 15.0, 100)
    pd = ArrayPlotData(index = x)

    # Plot some bessel functions and add the plots to our container
    for i in range(9):
        pd.set_data("y" + str(i), jn(i,x))
        plot = Plot(pd)
        plot.plot(("index", "y" + str(i)),
                  color=tuple(COLOR_PALETTE[i]), line_width=2.0,
                  bgcolor = "white", border_visible=True)

        # Tweak some of the plot properties
        plot.border_width = 1
        plot.padding = 10

        # Set each plot's aspect ratio based on its position in the
        # 3x3 grid of plots.
        n,m = divmod(i, 3)
        plot.aspect_ratio = float(n+1) / (m+1)

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

        # Add to the grid container
        container.add(plot)
    return container
开发者ID:brycehendrix,项目名称:chaco,代码行数:37,代码来源:grid_container_aspect_ratio.py

示例12: _create_plot_component

# 需要导入模块: from enthought.chaco.api import ArrayPlotData [as 别名]
# 或者: from enthought.chaco.api.ArrayPlotData import set_data [as 别名]
def _create_plot_component():

    # Create some data
    numpts = 1000
    x = sort(random(numpts))
    y = random(numpts)
    color = exp(-(x**2 + y**2))

    # Create a plot data obect and give it this data
    pd = ArrayPlotData()
    pd.set_data("index", x)
    pd.set_data("value", y)
    pd.set_data("color", color)

    # Create the plot
    plot = Plot(pd)
    plot.plot(("index", "value", "color"),
              type="cmap_scatter",
              name="my_plot",
              color_mapper=jet,
              marker = "square",
              fill_alpha = 0.5,
              marker_size = 6,
              outline_color = "black",
              border_visible = True,
              bgcolor = "white")

    # Tweak some of the plot properties
    plot.title = "Colormapped Scatter Plot"
    plot.padding = 50
    plot.x_grid.visible = False
    plot.y_grid.visible = False
    plot.x_axis.font = "modern 16"
    plot.y_axis.font = "modern 16"

    # Right now, some of the tools are a little invasive, and we need the
    # actual ColomappedScatterPlot object to give to them
    cmap_renderer = plot.plots["my_plot"][0]

    # Attach some tools to the plot
    plot.tools.append(PanTool(plot, constrain_key="shift"))
    zoom = ZoomTool(component=plot, tool_mode="box", always_on=False)
    plot.overlays.append(zoom)
    selection = ColormappedSelectionOverlay(cmap_renderer, fade_alpha=0.35,
                                            selection_type="mask")
    cmap_renderer.overlays.append(selection)

    # Create the colorbar, handing in the appropriate range and colormap
    colorbar = create_colorbar(plot.color_mapper)
    colorbar.plot = cmap_renderer
    colorbar.padding_top = plot.padding_top
    colorbar.padding_bottom = plot.padding_bottom

    # Create a container to position the plot and the colorbar side-by-side
    container = HPlotContainer(use_backbuffer = True)
    container.add(plot)
    container.add(colorbar)
    container.bgcolor = "lightgray"
    return container
开发者ID:brycehendrix,项目名称:chaco,代码行数:61,代码来源:cmap_scatter.py

示例13: __init__

# 需要导入模块: from enthought.chaco.api import ArrayPlotData [as 别名]
# 或者: from enthought.chaco.api.ArrayPlotData import set_data [as 别名]
    def __init__(self, index, value, *args, **kw):
        super(PlotExample, self).__init__(*args, **kw)

        plot_data = ArrayPlotData(index=index)
        plot_data.set_data("value", value)

        self.plot = Plot(plot_data)
        line = self.plot.plot(("index", "value"))[0]

        line.overlays.append(XRayOverlay(line))
        line.tools.append(BoxSelectTool(line))
开发者ID:brycehendrix,项目名称:chaco,代码行数:13,代码来源:xray_plot.py

示例14: _create_plot_component

# 需要导入模块: from enthought.chaco.api import ArrayPlotData [as 别名]
# 或者: from enthought.chaco.api.ArrayPlotData import set_data [as 别名]
def _create_plot_component():

    # Create some data
    numpts = 1000
    x = numpy.arange(0, numpts)
    y = numpy.random.random(numpts)
    marker_size = numpy.random.normal(4.0, 4.0, numpts)

    # Create a plot data object and give it this data
    pd = ArrayPlotData()
    pd.set_data("index", x)
    pd.set_data("value", y)

    # Because this is a non-standard renderer, we can't call plot.plot, which
    # sets up the array data sources, mappers and default index/value ranges.
    # So, its gotta be done manually for now.

    index_ds = ArrayDataSource(x)
    value_ds = ArrayDataSource(y)

    # Create the plot
    plot = Plot(pd)
    plot.index_range.add(index_ds)
    plot.value_range.add(value_ds)

    # Create the index and value mappers using the plot data ranges
    imapper = LinearMapper(range=plot.index_range)
    vmapper = LinearMapper(range=plot.value_range)

    # Create the scatter renderer
    scatter = VariableSizeScatterPlot(
                    index=index_ds,
                    value=value_ds,
                    index_mapper = imapper,
                    value_mapper = vmapper,
                    marker='circle',
                    marker_size=marker_size,
                    color=(1.0,0.0,0.75,0.4))

    # Append the renderer to the list of the plot's plots
    plot.add(scatter)
    plot.plots['var_size_scatter'] = [scatter]

    # Tweak some of the plot properties
    plot.title = "Scatter Plot"
    plot.line_width = 0.5
    plot.padding = 50

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

    return plot
开发者ID:brycehendrix,项目名称:chaco,代码行数:56,代码来源:variable_sized_scatter.py

示例15: _plot_default

# 需要导入模块: from enthought.chaco.api import ArrayPlotData [as 别名]
# 或者: from enthought.chaco.api.ArrayPlotData import set_data [as 别名]
 def _plot_default(self):
     outcomes, results, time = self._prepare_data()
     
     # get the x,y data to plot
     pds = []    
     for outcome in outcomes:
         pd  = ArrayPlotData(index = time)
         result = results.get(outcome)
         for j in range(result.shape[0]): 
             pd.set_data("y"+str(j), result[j, :] )
         pds.append(pd)
     
     # Create a container and add our plots
     container = GridContainer(
                               bgcolor="white", use_backbuffer=True,
                               shape=(len(outcomes),1))
 
     #plot data
     tools = []
     for j, outcome in enumerate(outcomes):
         pd1 = pds[j]
 
         # Create some line plots of some of the data
         plot = Plot(pd1, title=outcome, border_visible=True, 
                     border_width = 1)
         plot.legend.visible = False
     
         a = len(pd1.arrays)- 1
         if a > 1000:
             a = 1000
         for i in range(a):
             plotvalue = "y"+str(i)
             color = colors[i%len(colors)]
             plot.plot(("index", plotvalue), name=plotvalue, color=color)
             
         for value in plot.plots.values():
             for entry in value:
                 entry.index.sort_order = 'ascending'
 
         # Attach the selector tools to the plot
         selectorTool1 = LineSelectorTool(component=plot)
         plot.tools.append(selectorTool1)
         tools.append(selectorTool1)
         container.add(plot)
 
     #make sure the selector tools know each other
     
     for tool in tools:
         a = set(tools) - set([tool])
         tool._other_selectors = list(a)
         tool._demo = self
 
     return container
开发者ID:canerhamarat,项目名称:EMAworkbench,代码行数:55,代码来源:interactive_graphs.py


注:本文中的enthought.chaco.api.ArrayPlotData.set_data方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。