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.

Screenshot

screenshot

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.4.tar.gz (11.7 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.4-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: quatplot-0.1.4.tar.gz
  • Upload date:
  • Size: 11.7 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.4.tar.gz
Algorithm Hash digest
SHA256 0de7bed224ec0dcf2428f46f0a6c409655bd503761c92db95a5a7c4d400de3c4
MD5 538db54edf43c7f6c738c0046340b8a9
BLAKE2b-256 fcbcd603b02575e2f0ca5394311bc303a90ccf956cc4270ce16c6728a4323838

See more details on using hashes here.

File details

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

File metadata

  • Download URL: quatplot-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 12.7 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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 1de4e8dabadb3b10a3bc6d09eae1183dfeecc8a7a44737e4c68add85ab8fcba2
MD5 702454f962ad58882f89844cf1adb3e8
BLAKE2b-256 81047289304385baf55fb9157769a739f50369b6538f256a6b166c98b1d65d9b

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