Skip to main content

Matplotlib extension to make stereograms

Project description

Release Builds Tests PyPI - Python Version

mpl_stereo

Matplotlib add-on to make stereograms.

Stereograms can significantly enhance the interpretability of 3D data by leveraging human binocular vision. Instead of trying to imagine how the flat projection of 3D data on a page would look in real life, stereograms give us "3D glasses" for 2D data with just our eyes.

It takes some practice to be able to view the stereoscopic effect for the first time, but the effort is well worth it!

Usage

Installation

pip install mpl_stereo

Setup

import numpy as np
from mpl_stereo import AxesStereo2D, AxesStereo3D

# Generate some data, here a (3,2) trefoil knot
t = np.linspace(0, 2*np.pi, 100)
x = np.cos(2*t) * (3 + np.cos(3*t))
y = np.sin(2*t) * (3 + np.cos(3*t))
z = np.sin(3*t)

2D plots

Currently, only a subset of matplotlib's 2D plots are officially supported. See the list by calling axstereo.known_methods.

axstereo = AxesStereo2D()
axstereo.plot(x, y, z, c='k', alpha=0.2)
axstereo.scatter(x, y, z, c=z, cmap='viridis', s=10)

If you can see view the stereogram properly, you should see the knot weave in and out of the page!

3D plots

The stereoscopic effect in 3D can be made just by rotating the plot view, so all of matplotlib's 3D plot types are supported.

axstereo = AxesStereo2D()
axstereo.plot(x, y, z, c='k', alpha=0.2)
axstereo.scatter(x, y, z, c=z, cmap='viridis', s=10)

Viewing Stereograms

These are not autostereograms, 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.

  1. Position the Stereogram: Place it at arm's length and ensure it's level with your eyes.
  2. Relax Your Focus: Look through the image, as if focusing on something distant, rather than the stereogram itself.
  3. Parallel Viewing: Try to view the image with your eyes parallel, similar to how you would look at a distant object.
  4. Align and Overlap: Adjust the angle and distance of the stereogram until the two images begin to overlap.
  5. Perceive the 3D Image: As the images overlap, a 3D image should emerge. Keep your focus steady to maintain the illusion.
  6. Practice: If initially unsuccessful, take breaks and try again. It might require some practice to get used to this method.

Parallel vs Cross-Eyed Viewing

By default, the stereograms are set up for "parallel" viewing method as described above. For "cross-eyed" viewing, initialize with a negative ipd "inter-pupilary distance". An ipd of 65 millimeters is the default, so call AxesStereo2D(ipd=-65) as a default cross-eyed method.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mpl_stereo-0.1.0.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

mpl_stereo-0.1.0-py3-none-any.whl (5.9 kB view details)

Uploaded Python 3

File details

Details for the file mpl_stereo-0.1.0.tar.gz.

File metadata

  • Download URL: mpl_stereo-0.1.0.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.8.10 Linux/5.10.102.1-microsoft-standard-WSL2

File hashes

Hashes for mpl_stereo-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a3f3bed611bb3e26ea551270280dd40e5597be4e0910e790f81379663f2fee7a
MD5 b3f4d5a29bd3e3261197344851e22ee7
BLAKE2b-256 f1f124f58d4354f71d1d25a8b8b40a9a7ece8c270da13b199d00f5e90254b613

See more details on using hashes here.

Provenance

File details

Details for the file mpl_stereo-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: mpl_stereo-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.8.10 Linux/5.10.102.1-microsoft-standard-WSL2

File hashes

Hashes for mpl_stereo-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cd06683da626add00ae2dadc87e101ac923fabaa2cbb4874e78c76f6b928aa2b
MD5 2727ede51e1caa908581806cd0b1cc85
BLAKE2b-256 ea95268387f5cd09a5ff21f48b702001ac5f1e0b38c8d7ffcd3523fcf4ba7705

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page