mantid
mantid copied to clipboard
Crash when using log scale on Surface plots
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
- 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')
- Right click on data workspace and choose Plot->3D->Surface
- Click on the settings wheel in the toolbar
- Click on the Image Tab
- 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