mantidproject / mantid

Main repository for Mantid code
https://www.mantidproject.org
GNU General Public License v3.0
210 stars 122 forks source link

More than one image on same plot sharing colorbar causes error #33979

Closed DannyHindson closed 2 years ago

DannyHindson commented 2 years ago

Crash reported on Slack error-reports channel:

Name: Not provided  Email: Not provided
       Additional text:
       Not provided
       Stack Trace:
       Traceback (most recent call last):
 File "/net4/serdon/illdata/applications/apps/mantid/illdaily/opt/mantidunstable/lib/mantidqt/widgets/plotconfigdialog/presenter.py", line 96, in apply_properties_and_exit
   self.apply_properties()
 File "/net4/serdon/illdata/applications/apps/mantid/illdaily/opt/mantidunstable/lib/mantidqt/widgets/plotconfigdialog/presenter.py", line 77, in apply_properties
   tab.apply_properties()
 File "/net4/serdon/illdata/applications/apps/mantid/illdaily/opt/mantidunstable/lib/mantidqt/widgets/plotconfigdialog/imagestabwidget/presenter.py", line 48, in apply_properties
   image.set_interpolation(props.interpolation)
AttributeError: 'QuadMesh' object has no attribute 'set_interpolation'

This happens if you have two images plotted on the same axes sharing a color bar, where one of them is a QuadMesh. If you go into the plot options screen and hit apply on the Images tab you get the error. I think there's a small bug in qt/python/mantidqt/mantidqt/widgets/plotconfigdialog/imagestabwidget/presenter.py here:

    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
            test = self.image_names_dict.values()
            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 not isinstance(image, Poly3DCollection)): <----
                image.set_interpolation(props.interpolation)

            update_colorbar_scale(self.fig, image, SCALES[props.scale], props.vmin, props.vmax)
mantid-builder commented 2 years ago

Fixed by #33990