mantidproject / mantid

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

Unhandled exception when changing colorscale to log with empty bins present and autoscaling on in Sliceviewer #33883

Closed RichardWaiteSTFC closed 2 years ago

RichardWaiteSTFC commented 2 years ago

(1) Load in CNCS_7860_event.nxs - zoom into a region that contains zero bins (2) Change colorscale to Log

Traceback (most recent call last):
  File "C:\MantidNightlyInstall\bin\lib\site-packages\matplotlib\cbook\__init__.py", line 287, in process
    func(*args, **kwargs)
  File "C:\MantidNightlyInstall\bin\lib\site-packages\matplotlib\colorbar.py", line 551, in update_normal
    self.draw_all()
  File "C:\MantidNightlyInstall\bin\lib\site-packages\matplotlib\colorbar.py", line 578, in draw_all
    self._process_values()
  File "C:\MantidNightlyInstall\bin\lib\site-packages\matplotlib\colorbar.py", line 1144, in _process_values
    b = self.norm.inverse(b)
  File "C:\MantidNightlyInstall\bin\lib\site-packages\matplotlib\colors.py", line 1554, in inverse
    raise ValueError("Invalid vmin or vmax")
ValueError: Invalid vmin or vmax
robertapplin commented 2 years ago

When trying to reproduce this, I found a slightly different and possibly related error. Happened when zooming out of the data and then zooming in to a region with no data. I then switched to Log with Autoscaling still checked:

Traceback (most recent call last):
  File "C:\Users\mlc47243\Documents\mantid-development\mantid-4\mantid\external\src\ThirdParty\lib\python3.8\lib\site-packages\matplotlib\backends\backend_qt5.py", line 506, in _draw_idle
    self.draw()
  File "C:\Users\mlc47243\Documents\mantid-development\mantid-4\mantid\external\src\ThirdParty\lib\python3.8\lib\site-packages\matplotlib\backends\backend_agg.py", line 388, in draw
    self.figure.draw(self.renderer)
  File "C:\Users\mlc47243\Documents\mantid-development\mantid-4\mantid\external\src\ThirdParty\lib\python3.8\lib\site-packages\matplotlib\artist.py", line 38, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "C:\Users\mlc47243\Documents\mantid-development\mantid-4\mantid\external\src\ThirdParty\lib\python3.8\lib\site-packages\matplotlib\figure.py", line 1708, in draw
    mimage._draw_list_compositing_images(
  File "C:\Users\mlc47243\Documents\mantid-development\mantid-4\mantid\external\src\ThirdParty\lib\python3.8\lib\site-packages\matplotlib\image.py", line 135, in _draw_list_compositing_images
    a.draw(renderer)
  File "C:\Users\mlc47243\Documents\mantid-development\mantid-4\mantid\external\src\ThirdParty\lib\python3.8\lib\site-packages\matplotlib\artist.py", line 38, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "C:\Users\mlc47243\Documents\mantid-development\mantid-4\mantid\external\src\ThirdParty\lib\python3.8\lib\site-packages\matplotlib\axes\_base.py", line 2647, in draw
    mimage._draw_list_compositing_images(renderer, self, artists)
  File "C:\Users\mlc47243\Documents\mantid-development\mantid-4\mantid\external\src\ThirdParty\lib\python3.8\lib\site-packages\matplotlib\image.py", line 135, in _draw_list_compositing_images
    a.draw(renderer)
  File "C:\Users\mlc47243\Documents\mantid-development\mantid-4\mantid\external\src\ThirdParty\lib\python3.8\lib\site-packages\matplotlib\artist.py", line 38, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "C:\Users\mlc47243\Documents\mantid-development\mantid-4\mantid\external\src\ThirdParty\lib\python3.8\lib\site-packages\matplotlib\collections.py", line 2020, in draw
    self.update_scalarmappable()
  File "C:\Users\mlc47243\Documents\mantid-development\mantid-4\mantid\external\src\ThirdParty\lib\python3.8\lib\site-packages\matplotlib\collections.py", line 763, in update_scalarmappable
    self._facecolors = self.to_rgba(self._A, self._alpha)
  File "C:\Users\mlc47243\Documents\mantid-development\mantid-4\mantid\external\src\ThirdParty\lib\python3.8\lib\site-packages\matplotlib\cm.py", line 289, in to_rgba
    x = self.norm(x)
  File "C:\Users\mlc47243\Documents\mantid-development\mantid-4\mantid\external\src\ThirdParty\lib\python3.8\lib\site-packages\matplotlib\colors.py", line 1096, in __call__
    raise ValueError("values must all be positive")
ValueError: values must all be positive
Traceback (most recent call last):
  File "C:\Users\mlc47243\Documents\mantid-development\mantid-4\mantid\external\src\ThirdParty\lib\python3.8\lib\site-packages\matplotlib\backends\backend_qt5.py", line 506, in _draw_idle
    self.draw()
  File "C:\Users\mlc47243\Documents\mantid-development\mantid-4\mantid\external\src\ThirdParty\lib\python3.8\lib\site-packages\matplotlib\backends\backend_agg.py", line 388, in draw
    self.figure.draw(self.renderer)
  File "C:\Users\mlc47243\Documents\mantid-development\mantid-4\mantid\external\src\ThirdParty\lib\python3.8\lib\site-packages\matplotlib\artist.py", line 38, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "C:\Users\mlc47243\Documents\mantid-development\mantid-4\mantid\external\src\ThirdParty\lib\python3.8\lib\site-packages\matplotlib\figure.py", line 1708, in draw
    mimage._draw_list_compositing_images(
  File "C:\Users\mlc47243\Documents\mantid-development\mantid-4\mantid\external\src\ThirdParty\lib\python3.8\lib\site-packages\matplotlib\image.py", line 135, in _draw_list_compositing_images
    a.draw(renderer)
  File "C:\Users\mlc47243\Documents\mantid-development\mantid-4\mantid\external\src\ThirdParty\lib\python3.8\lib\site-packages\matplotlib\artist.py", line 38, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "C:\Users\mlc47243\Documents\mantid-development\mantid-4\mantid\external\src\ThirdParty\lib\python3.8\lib\site-packages\matplotlib\axes\_base.py", line 2647, in draw
    mimage._draw_list_compositing_images(renderer, self, artists)
  File "C:\Users\mlc47243\Documents\mantid-development\mantid-4\mantid\external\src\ThirdParty\lib\python3.8\lib\site-packages\matplotlib\image.py", line 135, in _draw_list_compositing_images
    a.draw(renderer)
  File "c:\users\mlc47243\documents\mantid-development\mantid-4\mantid\framework\pythoninterface\mantid\plots\resampling_image\samplingimage.py", line 75, in draw
    super().draw(renderer, *args, **kwargs)
  File "C:\Users\mlc47243\Documents\mantid-development\mantid-4\mantid\external\src\ThirdParty\lib\python3.8\lib\site-packages\matplotlib\artist.py", line 38, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "C:\Users\mlc47243\Documents\mantid-development\mantid-4\mantid\external\src\ThirdParty\lib\python3.8\lib\site-packages\matplotlib\image.py", line 618, in draw
    im, l, b, trans = self.make_image(
  File "C:\Users\mlc47243\Documents\mantid-development\mantid-4\mantid\external\src\ThirdParty\lib\python3.8\lib\site-packages\matplotlib\image.py", line 879, in make_image
    return self._make_image(
  File "C:\Users\mlc47243\Documents\mantid-development\mantid-4\mantid\external\src\ThirdParty\lib\python3.8\lib\site-packages\matplotlib\image.py", line 482, in _make_image
    output = self.norm(np.ma.masked_array(A_resampled, out_mask))
  File "C:\Users\mlc47243\Documents\mantid-development\mantid-4\mantid\external\src\ThirdParty\lib\python3.8\lib\site-packages\matplotlib\colors.py", line 1096, in __call__
    raise ValueError("values must all be positive")
ValueError: values must all be positive

I also got a similar error when switching to SymmetrixLog10:

Traceback (most recent call last):
  File "c:\users\mlc47243\documents\mantid-development\mantid-4\mantid\qt\python\mantidqt\mantidqt\widgets\colorbar\colorbar.py", line 210, in norm_changed
    self.set_mappable(self.colorbar.mappable)
  File "c:\users\mlc47243\documents\mantid-development\mantid-4\mantid\qt\python\mantidqt\mantidqt\widgets\colorbar\colorbar.py", line 154, in set_mappable
    self.colorbar = Colorbar(ax=self.ax, mappable=mappable)
  File "C:\Users\mlc47243\Documents\mantid-development\mantid-4\mantid\external\src\ThirdParty\lib\python3.8\lib\site-packages\matplotlib\colorbar.py", line 1183, in __init__
    ColorbarBase.__init__(self, ax, **kw)
  File "C:\Users\mlc47243\Documents\mantid-development\mantid-4\mantid\external\src\ThirdParty\lib\python3.8\lib\site-packages\matplotlib\colorbar.py", line 460, in __init__
    self.draw_all()
  File "C:\Users\mlc47243\Documents\mantid-development\mantid-4\mantid\external\src\ThirdParty\lib\python3.8\lib\site-packages\matplotlib\colorbar.py", line 493, in draw_all
    self._config_axes(X, Y)
  File "C:\Users\mlc47243\Documents\mantid-development\mantid-4\mantid\external\src\ThirdParty\lib\python3.8\lib\site-packages\matplotlib\colorbar.py", line 727, in _config_axes
    self.update_ticks()
  File "C:\Users\mlc47243\Documents\mantid-development\mantid-4\mantid\external\src\ThirdParty\lib\python3.8\lib\site-packages\matplotlib\colorbar.py", line 614, in update_ticks
    ticks, ticklabels, offset_string = self._ticker(locator, formatter)
  File "C:\Users\mlc47243\Documents\mantid-development\mantid-4\mantid\external\src\ThirdParty\lib\python3.8\lib\site-packages\matplotlib\colorbar.py", line 850, in _ticker
    b = np.array(locator())
  File "C:\Users\mlc47243\Documents\mantid-development\mantid-4\mantid\external\src\ThirdParty\lib\python3.8\lib\site-packages\matplotlib\ticker.py", line 2439, in __call__
    return self.tick_values(vmin, vmax)
  File "C:\Users\mlc47243\Documents\mantid-development\mantid-4\mantid\external\src\ThirdParty\lib\python3.8\lib\site-packages\matplotlib\ticker.py", line 2527, in tick_values
    decades.extend(b ** (np.arange(c_range[0], c_range[1], stride)))
ValueError: arange: cannot compute length

This is caused by the negative value in the box above the normalisation