Пример #1
0
 def updateplots(self):
     x = np.sort(np.random.random(100))
     y = np.random.random(100)
     color = np.exp(-(x ** 2 + y ** 2))  # np.random.random(100)
     pd = ArrayPlotData()
     pd.set_data("index", x)
     pd.set_data("value", y)
     pd.set_data("color", color)
     # Create some line plots of some of the data
     plot = Plot(pd)
     # Create a scatter plot and get a reference to it (separate from the
     # Plot object) because we'll need it for the regression tool below.
     scatterplot = plot.plot(
         ("index", "value", "color"),
         type="cmap_scatter",
         color_mapper=reverse(Spectral),
         marker="square",
         fill_alpha=0.9,
         marker_size=6,
         bgcolor=QtGui.QColor(240, 240, 240),
     )[0]
     # Tweak some of the plot properties
     plot.padding = 50
     # Attach some tools to the plot
     plot.tools.append(PanTool(plot, drag_button="right"))
     plot.overlays.append(ZoomTool(plot))
     # Add the regression tool and overlay.  These need to be added
     # directly to the scatterplot instance (and not the Plot instance).
     regression = RegressionLasso(scatterplot, selection_datasource=scatterplot.index)
     scatterplot.tools.append(regression)
     scatterplot.overlays.append(RegressionOverlay(scatterplot, lasso_selection=regression))
     self.chaco_widget1.visualization.plot = plot
     self.chaco_widget2.visualization.plot = plot
Пример #2
0
    def image_histogram_plot_component(self):
        xs = np.arange(0, len(self.im))
        ys = np.arange(0, len(self.im[0]))

        index = GridDataSource(xdata=xs,
                               ydata=ys,
                               sort_order=('ascending', 'ascending'))

        index_mapper = GridMapper(range=DataRange2D(index))

        color_source = ImageData(data=np.flipud(self.im), value_depth=1)
        reversed_grays = reverse(Greys)
        color_mapper = reversed_grays(DataRange1D(color_source))

        plot = CMapImagePlot(
            index=index,
            index_mapper=index_mapper,
            value=color_source,
            value_mapper=color_mapper,
        )

        #: Add overlay for zoom
        data_box_overlay = MyDataBox(
            component=plot,
            data_position=[0, 0],
            data_bounds=self.data_bounds,
        )

        move_tool = MoveTool(component=data_box_overlay)
        resize_tool = ResizeTool(component=data_box_overlay)
        data_box_overlay.tools.append(move_tool)
        data_box_overlay.tools.append(resize_tool)

        data_box_overlay.on_trait_change(self.update_position, 'position')
        data_box_overlay.on_trait_change(self.update_data_bounds, 'bounds')

        #: Add to plot
        plot.overlays.append(data_box_overlay)

        return plot
Пример #3
0
    def image_histogram_plot_component(self):
        xs = np.arange(0, len(self.im))
        ys = np.arange(0, len(self.im[0]))

        index = GridDataSource(xdata=xs,
                               ydata=ys,
                               sort_order=('ascending', 'ascending'))

        index_mapper = GridMapper(range=DataRange2D(index))

        color_source = ImageData(data=self.im, value_depth=1)
        reversed_grays = reverse(Greys)
        color_mapper = reversed_grays(DataRange1D(color_source))

        plot = CMapImagePlot(
            index=index,
            index_mapper=index_mapper,
            value=color_source,
            value_mapper=color_mapper,
            orientation='h',
            origin='top left',
        )

        self.data_box_overlay = DataBox(
            component=plot,
            data_position=[0, 0],
            data_bounds=[self.my_data_bounds, self.my_data_bounds],
        )

        move_tool = MoveTool(component=self.data_box_overlay)
        self.data_box_overlay.tools.append(move_tool)

        self.data_box_overlay.on_trait_change(self.update_my_position,
                                              'position')

        #: Add to plot
        plot.overlays.append(self.data_box_overlay)

        return plot
Пример #4
0
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with diamond. If not, see <http://www.gnu.org/licenses/>.

    Copyright (C) 2009-2016 Helmut Fedder <*****@*****.**>
"""

import numpy as np

from traits.api import Instance, Float, Range, Bool, Array, Str, Enum, Button, on_trait_change, Trait
from traitsui.api import View, Item, Group, HGroup, VGroup, VSplit, Tabbed, EnumEditor
from enable.api import ComponentEditor
from chaco.api import PlotAxis, CMapImagePlot, ColorBar, LinearMapper, ArrayPlotData, RdBu, reverse, PlotLabel
RdBu_r = reverse(RdBu)

from tools.chaco_addons import SaveHPlotContainer as HPlotContainer, SavePlot as Plot, SaveTool

# date and time tick marks
from chaco.scales.api import CalendarScaleSystem
from chaco.scales_tick_generator import ScalesTickGenerator

import threading
import time
import logging

from tools.emod import ManagedJob, FreeJob
from tools.cron import CronDaemon, CronEvent

from tools.utility import GetSetItemsMixin, warning