Skip to content

Commit

Permalink
generate animation and add to readme
Browse files Browse the repository at this point in the history
  • Loading branch information
scottshambaugh committed Dec 18, 2023
1 parent c1b5cf1 commit 5a0ff64
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
- Flesh out testing of 3D plotting
- 3D take into account roll angle
- Document derivation of offsets
- Animated stereogram example
- GH release publish to pypi

----

## [Unreleased]
### Added
* Animation example
### Changed
### Removed

Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ axstereo.set_xlabel('X Label')
(line_left, line_right) = axstereo.plot(x, y, z)
```

### Animations
See an example of how to use this with matplotlib animations in [docs/gen_graphics:animate_2d_trefoil](docs/gen_graphics.py).
<p float="left" align="center">
<img width="500" height="250" src="https://raw.githubusercontent.com/scottshambaugh/mpl_stereo/main/docs/trefoil_2d_animation.gif">
</p>


## Viewing Stereograms

These are not [*auto*stereograms](https://en.wikipedia.org/wiki/Autostereogram), like the "Magic Eye" books that were popular in the 1990's. However, they use the same viewing technique. Below is ChatGPT's how-to guide on viewing these, but I'll try to find a better beginner-friendly resource to put here.
Expand Down
4 changes: 2 additions & 2 deletions docs/gen_graphics.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import matplotlib.animation as animation
import matplotlib.pyplot as plt
from pathlib import Path
from mpl_stereo import AxesStereo2D, AxesStereo3D, AxesAnaglyph, calc_2d_offsets
from mpl_stereo import AxesStereo2D, AxesStereo3D, AxesAnaglyph, calc_2d_offsets, sort_by_z

N_STEPS = 10

Expand Down Expand Up @@ -60,7 +60,7 @@ def animate(frame):
return scatter

ani = animation.FuncAnimation(axstereo.fig, animate, frames=np.arange(N_STEPS), interval=20, repeat=False)
ani.save(savedir / "trefoil_animation.gif", fps=10, dpi=100)
ani.save(savedir / "trefoil_2d_animation.gif", fps=10, dpi=100)


def main():
Expand Down
Binary file added docs/trefoil_2d_animation.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 5a0ff64

Please sign in to comment.