Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add animated axes #2827

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Add animated axes #2827

wants to merge 5 commits into from

Conversation

vallsv
Copy link
Contributor

@vallsv vallsv commented Dec 12, 2019

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
  • Right axes looks to fail
  • Change from log/linear scale
  • User interaction have to cancel any transition

@vallsv
Copy link
Contributor Author

vallsv commented Dec 12, 2019

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
Copy link
Contributor Author

vallsv commented Jul 20, 2023

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 vallsv force-pushed the add-animated-axes branch 2 times, most recently from 6ec6fae to 7890356 Compare July 20, 2023 16:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant