예제 #1
0
    def apply_properties(self):
        props = self.view.get_properties()
        # if only one colorbar apply settings to all images
        if len(get_colorbars_from_fig(self.fig)) == 1:
            # flatten the values into one list
            images = sum(self.image_names_dict.values(), [])
        else:
            images = self.get_selected_image()

        for image in images:
            if image.colorbar:
                image.colorbar.set_label(props.label)

            image.set_cmap(props.colormap)
            if props.interpolation and not (isinstance(
                    image, QuadMesh) or isinstance(image, Poly3DCollection)):
                image.set_interpolation(props.interpolation)

            update_colorbar_scale(self.fig, image, SCALES[props.scale],
                                  props.vmin, props.vmax)

        if props.vmin > props.vmax:
            self.view.max_min_value_warning.setVisible(True)
            self.view.max_min_value_warning.setText(
                "<html> <head/> <body> <p> <span style=\"color:#ff0000;\">Max "
                "value is less than min value so they have been "
                "swapped.</span></p></body></html>")
        elif props.vmin == props.vmax:
            self.view.max_min_value_warning.setVisible(True)
            self.view.max_min_value_warning.setText(
                "<html><head/><body><p><span style=\"color:#ff0000;\">Min and max "
                "value are the same so they have been "
                "adjusted.</span></p></body></html>")
        else:
            self.view.max_min_value_warning.setVisible(False)
예제 #2
0
    def apply_properties(self):
        props = self.view.get_properties()
        image = self.get_selected_image()
        self.set_selected_image_label(props.label)
        image.set_cmap(props.colormap)
        if props.interpolation:
            image.set_interpolation(props.interpolation)

        update_colorbar_scale(self.fig, image, SCALES[props.scale], props.vmin,
                              props.vmax)

        if props.vmin > props.vmax:
            self.view.max_min_value_warning.setVisible(True)
            self.view.max_min_value_warning.setText(
                "<html> <head/> <body> <p> <span style=\"color:#ff0000;\">Max "
                "value is less than min value so they have been "
                "swapped.</span></p></body></html>")
        elif props.vmin == props.vmax:
            self.view.max_min_value_warning.setVisible(True)
            self.view.max_min_value_warning.setText(
                "<html><head/><body><p><span style=\"color:#ff0000;\">Min and max "
                "value are the same so they have been "
                "adjusted.</span></p></body></html>")
        else:
            self.view.max_min_value_warning.setVisible(False)
예제 #3
0
 def changes_accepted(self):
     super(ColorbarAxisEditor, self).changes_accepted()
     scale = Normalize
     if isinstance(self.images[0].norm, LogNorm):
         scale = LogNorm
     update_colorbar_scale(self.canvas.figure, self.images[0], scale,
                           self.limit_min, self.limit_max)
예제 #4
0
    def _change_colorbar_axes(self, scale_type):
        for ax in self.canvas.figure.get_axes():
            images = ax.get_images() + [col for col in ax.collections if isinstance(col, Collection)]
            for image in images:
                if image.norm.vmin is not None and image.norm.vmax is not None:
                    datafunctions.update_colorbar_scale(self.canvas.figure, image, scale_type, image.norm.vmin,
                                                        image.norm.vmax)

        self.canvas.draw_idle()
예제 #5
0
    def changes_accepted(self):
        self.ui.errors.hide()

        limit_min, limit_max = float(self.ui.editor_min.text()), float(self.ui.editor_max.text())

        scale = Normalize
        if isinstance(self.images[0].norm, LogNorm):
            scale = LogNorm

        if scale == LogNorm and (limit_min <= 0 or limit_max <= 0):
            raise ValueError("Limits must be positive\nwhen scale is logarithmic.")

        self.lim_setter(limit_min, limit_max)
        update_colorbar_scale(self.canvas.figure, self.images[0], scale, limit_min, limit_max)
예제 #6
0
    def changes_accepted(self):
        self.ui.errors.hide()

        if len(self.images) == 0:
            raise RuntimeError("Cannot find any plot linked to this colorbar")

        limit_min, limit_max = float(self.ui.editor_min.text()), float(self.ui.editor_max.text())

        scale = LogNorm if self.ui.logBox.isChecked() else Normalize

        if scale == LogNorm and (limit_min <= 0 or limit_max <= 0):
            raise ValueError("Limits must be positive\nwhen scale is logarithmic.")

        self.lim_setter(limit_min, limit_max)
        for img in self.images:
            update_colorbar_scale(self.canvas.figure, img, scale, limit_min, limit_max)