Skip to main content

Interactive 3D plots for Jupyter with quaternion-based view controls (ganja.js) - no gimbal lock

Project description

quatplot

Interactive 3D plots for Jupyter with quaternion-based view controls — no gimbal lock.

Quaternion math is powered by ganja.js (Algebra(0,2) ≅ ℍ) when its CDN is reachable, with a built-in quaternion fallback otherwise. Rendering is plain HTML5 canvas inside an <iframe srcdoc>, so plots are self-contained: multiple plots per notebook can't collide on IDs, CSS, or globals, and no notebook-side JavaScript is required.

Features

  • Surface plots from 2D mesh data (colored fill and/or wireframe, toggleable)
  • 3D scatter plots with colored markers and hover coordinate tooltips
  • Optional color bar for scatter values
  • Isometric ⇄ perspective projection toggle
  • Plotly-style mouse controls: drag to rotate, wheel to zoom, shift-drag / right-drag to pan
  • Top view button (straight down, x right / y up — isometric top view reads as a 2D plot)
  • Auto-scaled, labeled axes with nice-number tick marks
  • Light / dark themes; Viridis, Plasma, Jet, Coolwarm, Grayscale colormaps
  • PNG screenshot button
  • Resizable plots in Jupyter: drag the bottom-right corner
  • Standalone HTML export

Install

pip install git+https://github.com/drscotthawley/quatplot.git

(or uv pip install ...; PyPI release may follow).

Usage

import numpy as np
import quatplot as qp

x = np.linspace(-3, 3, 41)
y = np.linspace(-3, 3, 41)
X, Y = np.meshgrid(x, y)
Z = np.sin(X) * np.cos(Y)

qp.plot(qp.Surface(x, y, Z))                       # in a notebook cell

qp.plot(qp.Scatter3(px, py, pz, v=values),         # scatter, colored by v
        colorbar=True, cmap="Plasma")

qp.plot(qp.Surface(x, y, Z), qp.Scatter3(px, py, pz),  # overlay traces
        theme="light", proj="perspective", height=600)

qp.save("plot.html", qp.Surface(x, y, Z))          # standalone HTML file

plot() options: theme ("dark"/"light"), proj ("iso"/"perspective"), cmap, fill, wire, colorbar, height (initial px; plots are corner-drag resizable afterward).

See examples/quatplot_demo.ipynb for a working tour.

Development

git clone https://github.com/drscotthawley/quatplot.git
cd quatplot
pip install -e .

The entire library is one file, quatplot.py; the HTML/JS template embedded in it is the single source of truth for both notebook rendering and HTML export.

License

MIT — see LICENSE.

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

quatplot-0.1.2.tar.gz (11.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

quatplot-0.1.2-py3-none-any.whl (12.5 kB view details)

Uploaded Python 3

File details

Details for the file quatplot-0.1.2.tar.gz.

File metadata

  • Download URL: quatplot-0.1.2.tar.gz
  • Upload date:
  • Size: 11.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.18

File hashes

Hashes for quatplot-0.1.2.tar.gz
Algorithm Hash digest
SHA256 336ab4e45e7fca6d5493f80fce8c460c707faa2fdd59af7ec67ce3f98e03142b
MD5 f55645754a50a771a83ec8230d0c3ac1
BLAKE2b-256 66f23d7b0d1099d268382249cf59bccbcbe7091efb490192fbc20f76e74fa333

See more details on using hashes here.

File details

Details for the file quatplot-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: quatplot-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 12.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.18

File hashes

Hashes for quatplot-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 436490daed8a88ff1980e59a94296cbb3519c29563e2a16aa2750a1d06406aaf
MD5 c5a69213bc0da78c1ca19b021e8e13f9
BLAKE2b-256 aa0a74e51afb59d33400d54190405e0bad9eebec650acd4d6edaa34a99c737cf

See more details on using hashes here.

Supported by

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