示例#1
0
    def update(self, view=None):
        """
        Redraw the layer
        """
        if not self._visible:
            return

        self.clear()

        if self._coordinator.remove_artists:
            old = all_artists(self._axes.figure)

        if isinstance(self._layer, Data):
            a = self._coordinator.plot_data(layer=self._layer)
        else:
            a = self._coordinator.plot_subset(layer=self._layer, subset=self._layer)

        # if user explicitly returns the newly-created artists,
        # then use them. Otherwise, introspect to find the new artists
        if a is None:
            if self._coordinator.remove_artists:
                self.artists = list(new_artists(self._axes.figure, old))
            else:
                self.artists = []
        else:
            self.artists = as_list(a)

        for a in self.artists:
            a.set_zorder(self.zorder)
示例#2
0
    def _call_udf(self, method_name, **kwargs):
        """
        Call a user-defined function stored in the _custom_functions dict

        Parameters
        ----------
        method_name : str
           The name of the user-defined method to setup a dispatch for
        **kwargs : dict
           Custom settings to pass to the UDF if they are requested by name
           as input arguments

        Returns
        -------
        The result of the UDF

        Notes
        -----
        This function builds the necessary arguments to the
        user-defined function. It also attempts to monitor
        the state of the matplotlib plot, removing stale
        artists and re-rendering the cavnas as needed.
        """

        # get the custom function
        try:
            func = self._custom_functions[method_name]
        except KeyError:
            return []

        # clear any MPL artists created on last call
        if self.remove_artists:
            layer = kwargs.get('layer', None)
            key = (layer, method_name)
            old = self._created_artists.get(key, set())
            remove_artists(old)
            current = all_artists(self.axes.figure)

        # add some extra information that the user might want
        kwargs.setdefault('_self', self)
        kwargs.setdefault('axes', self.axes)
        kwargs.setdefault('figure', self.axes.figure)
        kwargs.setdefault('state', self.state)

        # call method, keep track of newly-added artists
        settings = SettingsOracle(self._settings, **kwargs)
        result = introspect_and_call(func, settings)

        if self.remove_artists:
            new = new_artists(self.axes.figure, current)
            self._created_artists[key] = new
            if new:
                self.axes.figure.canvas.draw()
        else:
            self.axes.figure.canvas.draw()

        return result
示例#3
0
    def update(self, *args, **kwargs):

        if not self._visible:
            return

        self.clear()

        old = all_artists(self.axes.figure)

        if isinstance(self.state.layer, Data):
            a = self._coordinator.plot_data(layer=self.state.layer)
        else:
            a = self._coordinator.plot_subset(layer=self.state.layer, subset=self.state.layer)

        # if user explicitly returns the newly-created artists,
        # then use them. Otherwise, introspect to find the new artists
        if a is None:
            self.mpl_artists = list(new_artists(self.axes.figure, old))
        else:
            self.mpl_artists = as_list(a)

        for a in self.mpl_artists:
            a.set_zorder(self.state.zorder)
示例#4
0
    def update(self, *args, **kwargs):

        if not self._visible:
            return

        self.clear()

        old = all_artists(self.axes.figure)

        if isinstance(self.state.layer, BaseData):
            a = self._coordinator.plot_data(layer=self.state.layer)
        else:
            a = self._coordinator.plot_subset(layer=self.state.layer,
                                              subset=self.state.layer)

        # if user explicitly returns the newly-created artists,
        # then use them. Otherwise, introspect to find the new artists
        if a is None:
            self.mpl_artists = list(new_artists(self.axes.figure, old))
        else:
            self.mpl_artists = as_list(a)

        for a in self.mpl_artists:
            a.set_zorder(self.state.zorder)