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 quatplot

Or the latest development version straight from GitHub:

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

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 the demo notebook 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.3.tar.gz (11.6 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.3-py3-none-any.whl (12.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: quatplot-0.1.3.tar.gz
  • Upload date:
  • Size: 11.6 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.3.tar.gz
Algorithm Hash digest
SHA256 56e996d01c69429877f1a2569224fe898e6c2f53606cb9c34133560f1576f27b
MD5 c95f6111e9702420d9d74d2ed724cb51
BLAKE2b-256 de72e6049269b6af55c2784d6aefe9b599a1810ad0cb42a2fc4464127f1a4f8d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: quatplot-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 12.6 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 3ddde8294d4ae227ba8df3b6642cc95e80e8d69797822a8f387d976e7cba1938
MD5 3b5d61a9dfdfa048b43ce6148e88ee85
BLAKE2b-256 489eeb0c1d584775c8138ebced2569b75ff9a6f7d0ae9a276cf13456c91e2c15

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