Ejemplo n.º 1
0
    def rename_variable(self, toast: Toast, var_name: str,
                        display_name: str) -> None:
        """Update the legend label of the given variable.

        If a dataframe name is specified, the legend labels of all the columns are changed
        accordingly.

        Parameters
        ----------
        toast: Toast
            The `Toast` class instance.

        var_name: str
            The name of the variable to change the label of, as it is defined in Python.
            Can be a series or dataframe name.

        display_name: str
            The desired legend label.
        """
        try:
            return self.active_view.rename_variable(toast, var_name,
                                                    display_name)
        except NotImplementedError:
            toast.show(f"{self._active} does not implement variable renaming",
                       ToastType.warning)
Ejemplo n.º 2
0
 def freeze(self, toast: Toast) -> None:
     """Set the plotter to frozen, preventing new traces from being added."""
     try:
         return self.active_view.freeze(toast)
     except NotImplementedError:
         toast.show(f"{self._active} does not implement freeze",
                    ToastType.warning)
Ejemplo n.º 3
0
 def defrost(self, toast: Toast) -> None:
     if self._frozen:
         toast.show(
             "Dtale is 'defrosted'. DFs defined while it was frozen will not be automatically picked up. Use --show "
             " to get them added.",
             ToastType.info,
         )
     self._frozen = False
Ejemplo n.º 4
0
    def defrost(self, toast: Toast) -> None:
        """Set the plotter to un-frozen, allowing new traces to be plotted.

        Note that traces defined while it was frozen will need to be added manually.
        """
        try:
            return self.active_view.defrost(toast)
        except NotImplementedError:
            toast.show(f"{self._active} does not implement defrost",
                       ToastType.warning)
Ejemplo n.º 5
0
    def update_max_series_length(self, toast: Toast, sample: int) -> None:
        """Update the maximum series length of all traces.

        If this has an effect on any of the traces, set `self._changed` to `True`.

        Parameters
        ----------
        max_length: int
            The new maximum series length. If 0, the traces will not be downsampled.
        """
        try:
            return self.active_view.update_max_series_length(toast, sample)
        except NotImplementedError:
            toast.show(f"{self._active} does not implement max series length",
                       ToastType.warning)
Ejemplo n.º 6
0
    def set_plot_width(self, toast: Toast, width: int) -> None:
        """Validate and set the width of the figure.

        Parameters
        ----------
        toast: Toast
            The `Toast` class instance.

        width: int
            The desired width of the plot in inches. If outside the range `[_MIN_WIDTH,
            _MAX_WIDTH]`, will be set to the nearest limit and the user will be notified.
        """
        try:
            return self.active_view.set_plot_width(toast, width)
        except NotImplementedError:
            toast.show(
                f"{self._active} does not implement setting the plot height",
                ToastType.warning)
Ejemplo n.º 7
0
    def set_ylabel(self, toast: Toast, ylabel: str) -> None:
        """Set the y axis label.

         If the new label is different, set `self._changed` to True.

         Parameters
         ----------
         toast: Toast
             The `Toast` class instance.

         ylabel: str
             New label for the y axis. If it is an empty string, no label will be used.
         """
        try:
            return self.active_view.set_ylabel(toast, ylabel)
        except NotImplementedError:
            toast.show(f"{self._active} does not implement changing ylabel",
                       ToastType.warning)
Ejemplo n.º 8
0
    def ignore_variable(self, toast: Toast, var_name: str) -> None:
        """Hide the given variable from the plot. Undoes `show_variable`.

        If a dataframe name is specified, all of its columns will be hidden.

        Parameters
        ----------
        toast: Toast
            The `Toast` class instance.

        var_name: str
            Name of the variable to hide, as it is defined in Python. Can be a series
            names or dataframe name.
        """
        try:
            return self.active_view.ignore_variable(toast, var_name)
        except NotImplementedError:
            toast.show(f"{self._active} does not implement ignoring variables",
                       ToastType.warning)
Ejemplo n.º 9
0
    def change_colour(self, toast: Toast, var_name: str, colour: str) -> None:
        """Update the colour of the given variable.

        Only series / column names can be specified, not dataframe names.

        Parameters
        ----------
        toast: Toast
            The `Toast` class instance.

        var_name: str
            The name of the variable to change the colour of, as it is defined in Python.

        colour: str
            The desired trace colour. Must be a valid matplotlib colour.
        """
        try:
            return self.active_view.change_colour(toast, var_name, colour)
        except NotImplementedError:
            toast.show(f"{self._active} does not implement changing colours",
                       ToastType.warning)
Ejemplo n.º 10
0
    def show_variable(self, toast: Toast, var_name: str) -> None:
        """Show the given variable on the plot. Undoes `ignore_variable`.

        If a dataframe name is specified, all of its columns will be shown.

        Parameters
        ----------
        plotted_dfs: Dict[str, Set[str]]
            Dictionary with key = dataframe name, value = set of plotted column names.

        toast: Toast
            The `Toast` class instance.

        var_name: str
            Name of the variable to show, as it is defined in Python. Can be a series
            names or dataframe name.
        """
        try:
            return self.active_view.show_variable(toast, var_name)
        except NotImplementedError:
            toast.show(f"{self._active} does not implement showing variables",
                       ToastType.warning)
Ejemplo n.º 11
0
 def freeze(self, toast: Toast) -> None:
     if not self._frozen:
         toast.show(
             "Dtale is 'frozen'. New DFs will not be tracked, but tracked ones will still update.", ToastType.info
         )
     self._frozen = True