Skip to main content

Fully-vector, publication-style 3D-looking molecule/crystal figures from ASE Atoms

Project description

crystalvase logo

crystalvase

Tool for generating true vector figures of ASE structures with matplotlib.

crystalvase preview

(the very same figure as true vector: docs/preview.pdf)

Install

pip install -e .              # everything included; deps: ase, numpy, matplotlib, pillow

Use

from ase.io import read
import crystalvase as cv

atoms = read("POSCAR")
cv.write(atoms, "struct.pdf")                                 # defaults (below)
cv.write(atoms, "struct.jpg", rotation="45x,10y,0z", style="cartoon", dpi=300)
cv.write(atoms, "labelled.pdf", label="formula")             # formula below the figure
cv.render(atoms, ax)                                          # or draw onto your own Axes

# several structures in one figure (per-panel overrides), saved to png + pdf
cv.grid([(a1, dict(style="clean")), (a2, dict(palette="emerald"))],
        ncols=2, label="formula", save=["fig.png", "fig.pdf"])
crystalvase POSCAR out.pdf
crystalvase traj.xyz out.png --index ::10 --style cartoon     # slice -> one file per frame

Defaults: palette blossom, style realistic, size large, near-face-on view. Format is taken from the extension. Main options (API kwargs = CLI flags): rotation (ASE "<a>x,<b>y,<c>z" syntax), palette, style, radius_scale ("small" / "medium" / "large" / "xlarge" or a number), show_cell, reduce_cell, rings (gradient rings per sphere, default 220 — fewer gives much smaller vector files, e.g. rings=40 for many-panel figures), cell_color / cell_width (unit-cell wireframe — any matplotlib colour: black, lightgray, dimgray, "0.3", #444, …), label (text below the figure — label="formula" for the chemical formula — with label_size / label_weight / label_rotation; default extra-bold), plus figsize/dpi/background for saving.

Palettes & styles

  • Palettes: jmol (ASE default), vesta, vmd; tone variants of the ASE colours (pastel, muted, vivid, deep); and tone schemes where every element keeps its hue family but converges on a common tone (the way forest/mint/olive/neon are all greens) — forest, wine, emerald, olive, mint, blossom (default), tropical, neon, sage, midnight. Roll your own with cv.adjust(...) (multiplicative tweaks) or cv.retone("jmol", hue=..., sat=..., value=...) (pull towards a tone).
  • Styles (shading only), all depth-shaded so structure stays clear: clean — bright matte spheres, no outline, black cell box (MD-snapshot look); cartoon — flat "sticker" discs shaded at the edges, outlined (cartoon-dot adds a gloss dot, cartoon-soft is smooth matte pastel); realistic — studio-lit gloss, the default (realistic-warm, realistic-cool); ase — classic flat ASE look, outlined + depth-dimmed (ase-shaded). Custom: cv.make_style(edge_dark=0.6, hot_amt=1.0, ...) — see styles.py.

crystalvase --list-palettes / --list-styles print the choices; examples/ compares them. Run the tests with pytest. MIT licensed.

Reference galleries

Pick a style, palette and radius_scale by eye. Regenerate with python docs/make_gallery.py (self-contained — builds its own demo structures).

Styles (water box, jmol):

styles

Palettes (default style):

palettes

Sizes (radius_scale):

sizes

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

crystalvase-0.1.0.tar.gz (23.0 kB view details)

Uploaded Source

Built Distribution

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

crystalvase-0.1.0-py3-none-any.whl (23.3 kB view details)

Uploaded Python 3

File details

Details for the file crystalvase-0.1.0.tar.gz.

File metadata

  • Download URL: crystalvase-0.1.0.tar.gz
  • Upload date:
  • Size: 23.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for crystalvase-0.1.0.tar.gz
Algorithm Hash digest
SHA256 04f6c0f0bf3180c21ad69079753d61f32ea716b2d415da2cdaa3d9a11284ab77
MD5 ca5c982637b49baf938f539200853b71
BLAKE2b-256 bf2761a8fd3b96f9fbb7dbb2c70fd65ccfa6f2051254ab896d64cbb8a653edae

See more details on using hashes here.

File details

Details for the file crystalvase-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: crystalvase-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 23.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.8

File hashes

Hashes for crystalvase-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 81bcf613bd474336ef19cd09a8bd6cd9cd46daed9bc947e03506261f5b0c6de5
MD5 cdee91e07eb9171882dd56ccbaaab8ec
BLAKE2b-256 e5941b14720c99cc2dcb56ac3c9a18c99386ed32f1044110c027f2e18209f07d

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