Skip to main content

MatterVis: Crystal Structure Visualization Toolkit

License: MIT Python Version PyPI CI

Overview

MatterVis is a Python toolkit for deterministic, publication-quality material visualization. Its lightweight core renders PNG/PDF/SVG on the CPU; Plotly, Dash/Web APIs, Textual, Cube isosurfaces, and animation encoders are optional frontends.

Key Features

  • Agent-ready CLI — Five explicit subcommands (inspect, capabilities, render, serve, tui) separate bounded diagnosis, dependency preflight, browser-free static output, Web service, and terminal interaction
  • Browser Viewer — Drag-and-drop CIF upload and interactive 3D display with Mesh3d atoms and bonds. Scatter3d fast rendering is used only when explicitly selected; atom count never changes the representation
  • Coordination Topology — Automatic coordination-number detection via the nearest-neighbour gap, continuous shape measure (CShM) classification against 12 ideal polyhedra (CN 4–12), planarity RMS, and prism/antiprism twist analysis
  • Publication Export — The base CPU backend renders PNG with per-pixel depth handling and emits true-vector PDF/SVG from the same backend-neutral geometry
  • Multi-Panel Figuresuniform_viewport(scenes) stamps a shared world-cube on any list of scenes so every build_figure call emits at the same physical length per pixel
  • Automation API — REST + WebSocket endpoints on the same Flask server; drive the viewer from notebooks, agents, or subprocesses
  • Zero Catalog Required — Ships with a bundled DAP-4.cif so mat-vis serve works out of the box


Unit Cell — DAP-4 unit cell (flat ORTEP with element colours)


Coordination Shell — A-site coordination with convex hull overlay (CN=9, tricapped trigonal prism)


Three Display Modes — Formula unit, unit cell, and coordination shell side by side


Publication-Quality Export — Colour ORTEP-style Matplotlib renderer with labels


Asymmetric Unit — Diagnostic crystallographic view with atom labels and unit-cell context

Installation

From PyPI (recommended)

pip install matter-vis

From source (development)

git clone https://github.com/SchrodingersCattt/MatterVis.git
cd MatterVis
python -m pip install "molcrys-kit>=0.7.0"
pip install -e .

All dependencies are declared in pyproject.toml; requires-python = ">=3.10". Install only the frontend the requested output needs:

Extra Adds
base CPU 3D and Matplotlib 2D PNG/PDF/SVG, inspection, ORTEP, rings, and polyhedra
[plotly] Interactive Plotly/WebGL HTML
[plotly-export] Plotly + Kaleido static export
[web] Dash, REST, WebSocket, compression, and Plotly
[tui] Textual terminal UI
[cube] Cube input inspection and isosurfaces
[animation] GIF/MP4 encoders
[all] Every optional frontend
[test] Test tools

Browser screenshots and the Web UI's default static export combine [web] with [plotly-export]. Ask the resolver for the exact combined command:

mat-vis capabilities --require web-screenshot --json
mat-vis capabilities --require static-web-export --json

MolCrysKit is required and is the only chemistry structure source. MatterVis does not fall back to private MolCrysKit fields or local chemistry heuristics.

Quick Start

CLI — one-liner from CIF to figure

Install MatterVis, then render a crystal structure with a single command:

# PNG with default ball-and-stick style
mat-vis inspect structure.cif --json
mat-vis render structure.cif -o figure.png --backend cpu --check --json
mat-vis render structure.cif -o figure.png --backend cpu --json

# True projected 2D ball-and-stick (Matplotlib; no 3D lighting)
mat-vis render structure.cif -o figure-2d.png --backend matplotlib --json \
  --view unit_cell --style ball_stick --camera-axis c --orthogonal

# PDF, full unit cell, ORTEP hatch marks over flat-shaded ellipsoids
mat-vis render structure.cif -o figure.pdf \
  --backend cpu --view unit_cell --style ortep --shading flat \
  --ortep-mode ortep_hatch --missing-adp-policy error

# Interactive HTML for supplementary information
mat-vis render structure.cif -o si_figure.html --backend plotly \
  --show-hydrogen --show-labels

# Launch the interactive browser viewer
python -m pip install "matter-vis[web]"
mat-vis serve --cif structure.cif

See docs/cli.md for the full flag reference and common recipes.

Python API — programmatic control

from mat_viewer.agent import load_structure, prepare_render, render
from mat_viewer.render.contracts import RenderSpec, ViewSpec

structure = load_structure("scripts/data/DAP-4.cif")
plan = prepare_render(
    structure,
    view=ViewSpec(display="unit_cell"),
    render_spec=RenderSpec(backend="cpu", width=900, height=720),
)
result = render(plan, output="dap4.svg", backend="cpu")

Command Line Interface

Installing MatterVis also installs the mat-vis command. The CLI is self-documenting; use --help at any level to see the exact arguments:

mat-vis --help
mat-vis inspect --help
mat-vis capabilities --help
mat-vis render --help
mat-vis serve --help
mat-vis tui --help

The main subcommands cover:

  • mat-vis inspect ... --json — bounded structure/source metadata for agents
  • mat-vis capabilities ... --json — availability and exact install commands
  • mat-vis render ... — render atomistic structures and trajectories from CIF, Cube, VASP, XYZ, ASE, and LAMMPS inputs to PNG/PDF/SVG/HTML/GIF/MP4
  • mat-vis serve ... — launch the interactive Dash browser viewer with drag-and-drop CIF upload, topology analysis, and REST + WebSocket API
  • mat-vis tui ... — terminal-based crystal structure viewer for headless servers and SSH sessions

Documentation

You are… Start here
Understanding the design Architecture
Using the library API Reference · CLI Reference
AI agent (calling MatterVis) Caller API Contracts
AI agent (modifying code) AGENTS.md · Developer Notes
Topology scores Scores Reference

mat_viewer/ — source code · scripts/ — runnable demo scripts · docs/ — full documentation

License

This project is licensed under the MIT License — see the LICENSE file for details.

Download files

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

Source Distribution

matter_vis-0.0.4.tar.gz (2.1 MB view details)

Uploaded Source

Built Distribution

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

matter_vis-0.0.4-py3-none-any.whl (560.2 kB view details)

Uploaded Python 3

File details

Details for the file matter_vis-0.0.4.tar.gz.

File metadata

  • Download URL: matter_vis-0.0.4.tar.gz
  • Upload date:
  • Size: 2.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for matter_vis-0.0.4.tar.gz
Algorithm Hash digest
SHA256 1e265386c83f8173b1c4de156d8aa6b296cef38e3b45eb0707b656b7cabda40c
MD5 9920fe284a76269f401bd8b5515bfdae
BLAKE2b-256 dd2222dedb04691c7047d6229679c7725237a845f02a79f260ce09871f2cc5a5

See more details on using hashes here.

Provenance

The following attestation bundles were made for matter_vis-0.0.4.tar.gz:

Publisher: release.yml on SchrodingersCattt/MatterVis

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file matter_vis-0.0.4-py3-none-any.whl.

File metadata

  • Download URL: matter_vis-0.0.4-py3-none-any.whl
  • Upload date:
  • Size: 560.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for matter_vis-0.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 2fd57c7bf3384bcce32596555fa4c99d280c799ac9376f0cb19bf4f87fba4a94
MD5 aed99191d853453ff9dd8c781f83795c
BLAKE2b-256 b29e20b88b5c82302882db9816cf5b9e48f2fd8c29c81d3041ad0ed1d80cb564

See more details on using hashes here.

Provenance

The following attestation bundles were made for matter_vis-0.0.4-py3-none-any.whl:

Publisher: release.yml on SchrodingersCattt/MatterVis

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

0.0.5

2 files

This release

0.0.4 This release

2 files

0.0.3

2 files

0.0.2

2 files

0.0.1

2 files

0.0.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page