silx icon indicating copy to clipboard operation
silx copied to clipboard

Add animated axes

Open vallsv opened this issue 5 years ago • 2 comments

This is a proposal to add animated axes to the plot. That's a way to provide a smooth transition between 2 states, when a new item is added or edited. It is really convenient with live data plot to avoid to lose the context.

This PR:

  • Creates a new object View to deal with that
  • The animation is computed based on time (in case of lag)
  • The transition is slow at start and end
  • An example is provided displaying and hiding automatically items in the plot.

The View returns the result by cheating on the dataRange of the plot. That's convenient but really dirty, that is why this PR have to be reworked. To make it clean, few things could be done:

  • The View have to be informed that the data range have changed
  • It must have the responsibility of the update of the axis location

As result this should provide a better way for axis synchronization. The current way is not really convenient in case of user interaction and when the plot is in fixed aspect ratio. In this cases both axis have to be updated at the same time, but the events are not synchronized. As result the synchronization between plots is difficult without blinking or inconsistencies.

Problem to solve

  • [ ] Better integration
  • [x] Right axes looks to fail
  • [ ] Change from log/linear scale
  • [ ] User interaction have to cancel any transition

vallsv avatar Dec 12 '19 18:12 vallsv

Traceback (most recent call last):
  File "/users/valls/workspace/silx.git/build/lib.linux-x86_64-3.7/silx/gui/plot/items/axis.py", line 148, in __tick
    plot.resetZoom()
  File "/users/valls/workspace/silx.git/build/lib.linux-x86_64-3.7/silx/gui/plot/PlotWidget.py", line 2830, in resetZoom
    self._forceResetZoom(dataMargins=dataMargins)
  File "/users/valls/workspace/silx.git/build/lib.linux-x86_64-3.7/silx/gui/plot/PlotWidget.py", line 2769, in _forceResetZoom
    xmin, xmax, ymin, ymax, ymin2, ymax2))
  File "/users/valls/workspace/silx.git/build/lib.linux-x86_64-3.7/silx/gui/plot/_utils/__init__.py", line 67, in addMarginsToLimits
    yRange = yMax - yMin

vallsv avatar Dec 12 '19 18:12 vallsv

I have rebased that PR.

At some point it fails with the following exception, but i am really excited about the feature.

For Flint it could be really useful because people spend there time changing context, animation here could help to follow the changes.

Traceback (most recent call last):
  File "/nobackup/lvalls1/valls/workspace/silx.git/build/lib.linux-x86_64-3.8/silx/gui/plot/items/axis.py", line 148, in __tick
    plot.resetZoom()
  File "/nobackup/lvalls1/valls/workspace/silx.git/build/lib.linux-x86_64-3.8/silx/gui/plot/PlotWidget.py", line 3218, in resetZoom
    self._forceResetZoom(dataMargins=dataMargins)
  File "/nobackup/lvalls1/valls/workspace/silx.git/build/lib.linux-x86_64-3.8/silx/gui/plot/PlotWidget.py", line 3174, in _forceResetZoom
    self.setLimits(
  File "/nobackup/lvalls1/valls/workspace/silx.git/build/lib.linux-x86_64-3.8/silx/gui/plot/PlotWidget.py", line 2553, in setLimits
    *self.getYAxis()._checkLimits(ymin, ymax),
  File "/nobackup/lvalls1/valls/workspace/silx.git/build/lib.linux-x86_64-3.8/silx/gui/plot/items/axis.py", line 280, in _checkLimits
    return _utils.checkAxisLimits(
  File "/nobackup/lvalls1/valls/workspace/silx.git/build/lib.linux-x86_64-3.8/silx/gui/plot/_utils/panzoom.py", line 61, in checkAxisLimits
    vmax = numpy.clip(vmax, min_, FLOAT32_SAFE_MAX)
  File "<__array_function__ internals>", line 200, in clip
  File "/nobackup/lvalls1/valls/Software/miniconda3/envs/silxenv/lib/python3.8/site-packages/numpy/core/fromnumeric.py", line 2180, in clip
    return _wrapfunc(a, 'clip', a_min, a_max, out=out, **kwargs)
  File "/nobackup/lvalls1/valls/Software/miniconda3/envs/silxenv/lib/python3.8/site-packages/numpy/core/fromnumeric.py", line 54, in _wrapfunc
    return _wrapit(obj, method, *args, **kwds)
  File "/nobackup/lvalls1/valls/Software/miniconda3/envs/silxenv/lib/python3.8/site-packages/numpy/core/fromnumeric.py", line 43, in _wrapit
    result = getattr(asarray(obj), method)(*args, **kwds)
  File "/nobackup/lvalls1/valls/Software/miniconda3/envs/silxenv/lib/python3.8/site-packages/numpy/core/_methods.py", line 161, in _clip
    return _clip_dep_invoke_with_casting(
  File "/nobackup/lvalls1/valls/Software/miniconda3/envs/silxenv/lib/python3.8/site-packages/numpy/core/_methods.py", line 115, in _clip_dep_invoke_with_casting
    return ufunc(*args, out=out, **kwargs)
TypeError: '>=' not supported between instances of 'NoneType' and 'float'

vallsv avatar Jul 20 '23 15:07 vallsv