GoFish Python
Python wrapper for GoFish Graphics, a declarative charting library.
Important: JavaScript is the source of truth for all rendering, layout, and reactivity. This Python package provides a syntax-similar API that translates Python calls to JavaScript execution. All interactive and animated graphics are handled by SolidJS in JavaScript.
Installation
Using pip
# Install the package
pip install gofish-graphics
# Install a JavaScript bridge (choose one):
pip install pythonmonkey # Recommended
# OR
pip install jsbridge
Using uv (Recommended)
# Install uv: https://github.com/astral-sh/uv
curl -LsSf https://astral.sh/uv/install.sh | sh
# Install the package
uv pip install gofish-graphics
# Install a JavaScript bridge (choose one):
uv pip install pythonmonkey # Recommended
# OR
uv pip install jsbridge
You also need the GoFish JavaScript bundle. Either:
- Install it as a sibling package in your monorepo
- Set
GOFISH_JS_PATHenvironment variable to thedistdirectory - The package will try to auto-detect it in common locations
Quick Start
from gofish import chart, spread, rect
# Data
alphabet = [
{"letter": "A", "frequency": 28},
{"letter": "B", "frequency": 55},
{"letter": "C", "frequency": 43},
]
# Create chart (JavaScript executes all rendering)
chart(alphabet).flow(spread("letter", dir="x")).mark(rect(h="frequency")).render(w=500, h=300, axes=True)
Architecture
JavaScript as Source of Truth
This wrapper follows the same pattern as Plotly and Bokeh:
- Python: Provides the API, data, and configuration
- JavaScript: Handles all rendering, layout computation, and reactivity
All GoFish features work through JavaScript:
- SolidJS reactivity for animations
- Interactive graphics via DOM events
- Complex layouts and coordinate transforms
- SVG rendering
How It Works
- Python API: You write Python code with syntax similar to JS GoFish
- Translation: Python calls are converted to JavaScript function calls
- Execution: JavaScript (via bridge) executes GoFish code
- Rendering: SolidJS renders interactive SVG to DOM or HTML
Usage
Basic Chart
from gofish import chart, spread, rect
data = [{"x": 1, "y": 10}, {"x": 2, "y": 20}]
chart(data).flow(spread("x", dir="x")).mark(rect(h="y")).render(w=500, h=300)
Stacked Bar Chart
from gofish import chart, spread, stack, rect
chart(data).flow(
spread("category", dir="x"),
stack("series", dir="y")
).mark(rect(h="value", fill="series")).render(w=500, h=300, axes=True)
With Pandas
import pandas as pd
from gofish import chart, spread, rect
df = pd.DataFrame({
"category": ["A", "B", "C"],
"value": [10, 20, 30]
})
chart(df).flow(spread("category", dir="x")).mark(rect(h="value")).render()
Jupyter Notebooks
from gofish import chart, spread, rect, display_jupyter
node = chart(data).flow(spread("x", dir="x")).mark(rect(h="y"))
display_jupyter(node, w=500, h=300, axes=True)
API Reference
Core Functions
chart(data, **options)- Create a new chartChartBuilder.flow(*operators)- Add operatorsChartBuilder.mark(mark)- Apply a markGoFishNode.render(**options)- Render the chart
Operators
spread(field, dir="x", ...)- Spread groupsstack(field, dir="y", ...)- Stack groupsscatter(field, x, y, ...)- Scatter plot positioninggroup(field)- Group by fieldderive(fn)- Transform datanormalize(field)- Normalize valuesrepeat(field)- Repeat itemslog(label)- Debug logging
Marks
rect(w, h, fill, ...)- Rectanglescircle(r, fill, ...)- Circlesline(stroke, ...)- Linesarea(stroke, opacity, ...)- Areasscaffold(w, h, ...)- Invisible guidesselect(layer_name)- Select from layer
Development
Setup with uv (Recommended)
# Clone repository
git clone <repo-url>
cd packages/gofish-python
# Install uv: https://github.com/astral-sh/uv
curl -LsSf https://astral.sh/uv/install.sh | sh
# Install in development mode with all dependencies
uv sync
# This installs:
# - Package in editable mode
# - Dev dependencies (pytest, black, mypy)
# - Optional dependencies available via extras
Setup with pip (Alternative)
# Clone repository
git clone <repo-url>
cd packages/gofish-python
# Install in development mode
pip install -e ".[dev]"
# Install JavaScript bridge
pip install pythonmonkey
Building GoFish JS Bundle
The Python wrapper needs the compiled GoFish JavaScript bundle:
# In packages/gofish-graphics
pnpm install
pnpm build
Development Commands
# Run tests
uv run pytest
# or
make test
# Format code
uv run black gofish_python/
# Type checking
uv run mypy gofish_python/
# Build distribution
uv build
# or
make build
# Clean build artifacts
make clean
Publishing
See PUBLISHING.md for detailed publishing instructions.
Quick version:
# 1. Update version in pyproject.toml
# 2. Build
uv build
# or
make build
# 3. Publish to PyPI
uv publish
# or
make publish
# Or test on TestPyPI first
make testpypi
Limitations
- JavaScript Bridge Required: You must install either
pythonmonkeyorjsbridge - JS Bundle Required: The GoFish JavaScript bundle must be available
- DOM Environment: For interactive rendering, a DOM (browser/Jupyter) is needed
- Performance: Python↔JavaScript interop has overhead; complex animations may be slower
Future Work
- Better DOM-less rendering (static SVG export)
- Improved error messages
- Type hints and type checking
- More comprehensive examples
- Event handling from Python
- Animation control from Python
License
MIT
Metadata
Release files for gofish-graphics 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| gofish_graphics-0.1.0.tar.gz | 14.1 kB | Without provenance | Details for gofish_graphics-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| gofish_graphics-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for gofish_graphics-0.1.0-py3-none-any.whl |
Total release size: 30.8 kB
Release files / gofish_graphics-0.1.0.tar.gz
| Download URL | gofish_graphics-0.1.0.tar.gz |
|---|---|
| Size | 14.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4c690f28ea0e7434567ab881bcb4e9a0c86ee6d1e03e499bde4e63d000afd1a4
|
|
BLAKE2b-256 checksum How to use checksums |
6a1c215f89178e0dfdd8da16c4aee471ccc5a5e64ea7d0b0beaa473795f60195
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.9 {"installer":{"name":"uv","version":"0.9.9"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / gofish_graphics-0.1.0-py3-none-any.whl
| Download URL | gofish_graphics-0.1.0-py3-none-any.whl |
|---|---|
| Size | 16.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ce8efc38bde122dbcaf0af734f036473cb3b7fda17d5c0e8469dd48b6d275dab
|
|
BLAKE2b-256 checksum How to use checksums |
ee13e32a364f7217015c94e599ad8164fbf49b83e0ee8a261490da5a5594a083
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.9 {"installer":{"name":"uv","version":"0.9.9"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for gofish-graphics 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.