mantid icon indicating copy to clipboard operation
mantid copied to clipboard

Crash when using log scale on Surface plots

Open sf1919 opened this issue 11 months ago • 0 comments

Original reporter: Max Skoda, ISIS

Describe the bug When trying to set the colorbar to logarithmic in the plot setting for a surface plot Mantid gives the following error and then crashes

Scale is set to logarithmic so non-positive min value has been changed to 0.0001.
Scale is set to logarithmic so non-positive min value has been changed to 0.0001.
Traceback (most recent call last):
  File "...\mambaforge\envs\mantid_69\lib\site-packages\mantidqt\widgets\plotconfigdialog\presenter.py", line 75, in apply_properties
    tab.apply_properties()
  File "...\mambaforge\envs\mantid_69\lib\site-packages\mantidqt\widgets\plotconfigdialog\axestabwidget\presenter.py", line 55, in apply_properties
    self._apply_properties_to_axes(ax)
  File "...\mambaforge\envs\mantid_69\lib\site-packages\mantidqt\widgets\plotconfigdialog\axestabwidget\presenter.py", line 120, in _apply_properties_to_axes
    ax.set_zscale(self.current_view_props["zscale"])
  File "...\mambaforge\envs\mantid_69\lib\site-packages\matplotlib\axes\_base.py", line 74, in wrapper
    return get_method(self)(*args, **kwargs)
  File "...\mambaforge\envs\mantid_69\lib\site-packages\matplotlib\axis.py", line 822, in _set_axes_scale
    ax._axis_map[name]._set_scale(value, **kwargs)
  File "...\mambaforge\envs\mantid_69\lib\site-packages\matplotlib\axis.py", line 779, in _set_scale
    self._scale = mscale.scale_factory(value, self, **kwargs)
  File "...\mambaforge\envs\mantid_69\lib\site-packages\matplotlib\scale.py", line 708, in scale_factory
    scale_cls = _api.check_getitem(_scale_mapping, scale=scale)
  File "...\Local\mambaforge\envs\mantid_69\lib\site-packages\matplotlib\_api\__init__.py", line 192, in check_getitem
    raise ValueError(
ValueError: 'Linear' is not a valid value for scale; supported values are 'linear', 'log', 'symlog', 'asinh', 'logit', 'function', 'functionlog', 'power', 'square'

I noticed that this only happens when trying to change it in the Image settings. Right clicking on the colorbar and changing it does not seem to crash.

To Reproduce

For example

  1. Use the following script from the documentation to create the correct workspace
import matplotlib.pyplot as plt

data = Load('MUSR00015189.nxs')
data = mtd['data_1'] # Extract individual workspace from group

fig, ax = plt.subplots(subplot_kw={'projection':'mantid3d'})
ax.plot_surface(data, cmap='viridis')

  1. Right click on data workspace and choose Plot->3D->Surface
  2. Click on the settings wheel in the toolbar
  3. Click on the Image Tab
  4. Change the Scale to Logarithmic - Mantid crashes

Expected behavior Mantid should not crash and the scale should change to Logarithmic

Screenshots

Platform/Version (please complete the following information):

  • OS: Windows v10 and IDAaaS
  • Mantid Version: 6.9 & Nightly 6.9.20240228.1632

sf1919 avatar Mar 01 '24 15:03 sf1919