Skip to content
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ Overlay arbitrary 3D vectors as arrows on the rendered image via a JSON file. Us


```bash
xyzrender ethanol.xyz --vectors ethanol_dip.json -o ethanol_dip.svg
xyzrender ethanol.xyz --vector ethanol_dip.json -o ethanol_dip.svg
```

Each entry in the JSON array defines one arrow:
Expand Down Expand Up @@ -1153,7 +1153,7 @@ Available rotation axes: `x`, `y`, `z`, `xy`, `xz`, `yz`, `yx`, `zx`, `zy`. Pref
| `--label-size PT` | Label font size (overrides preset) |
| `--cmap FILE` | Per-atom property colormap (Viridis, 1-indexed) |
| `--cmap-range VMIN VMAX` | Explicit colormap range (default: auto from file) |
| `--vectors FILE` | JSON file of vector arrows to overlay (see Vector arrows section) |
| `--vector FILE` | JSON file of vector arrows to overlay (see Vector arrows section) |
| `--vector-scale FACTOR` | Global length scale for all vector arrows (default: 1.0) |
| **Crystal** | |
| `--crystal [{vasp,qe}]` | Load as crystal via phonopy; format auto-detected or specify explicitly |
Expand Down
2 changes: 1 addition & 1 deletion docs/source/cli_reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ Full flag reference for `xyzrender`. See also `xyzrender --help`.

| Flag | Description |
|------|-------------|
| `--vectors FILE` | Path to a JSON file defining 3D vector arrows for overlay |
| `--vector FILE` | Path to a JSON file defining 3D vector arrows for overlay |
| `--vector-scale` | Global length multiplier for all vector arrows |

## GIF animations
Expand Down
2 changes: 1 addition & 1 deletion docs/source/examples/annotations.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ Overlay arbitrary 3D vectors as arrows on the rendered image via a JSON file. Us


```bash
xyzrender ethanol.xyz --vectors ethanol_dip.json -o ethanol_dip.svg
xyzrender ethanol.xyz --vector ethanol_dip.json -o ethanol_dip.svg
```

Each entry in the JSON array defines one arrow:
Expand Down
117 changes: 7 additions & 110 deletions examples/examples.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1360,122 +1360,19 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": null,
"id": "c2cb9dfe",
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" viewBox=\"0 0 800 500\" width=\"500\" height=\"auto\">\n",
" <rect width=\"100%\" height=\"100%\" fill=\"#ffffff\"/>\n",
" <defs>\n",
" <g id=\"x6a0\"><radialGradient id=\"x6g0\" cx=\".5\" cy=\".5\" fx=\".33\" fy=\".33\" r=\".66\"><stop offset=\"0%\" stop-color=\"#c3c3c3\"/><stop offset=\"100%\" stop-color=\"#888888\"/></radialGradient><circle cx=\"0\" cy=\"0\" r=\"59.0\" fill=\"url(#x6g0)\" stroke=\"#000000\" stroke-width=\"10.4\"/></g>\n",
" <g id=\"x6a1\"><radialGradient id=\"x6g1\" cx=\".5\" cy=\".5\" fx=\".33\" fy=\".33\" r=\".66\"><stop offset=\"0%\" stop-color=\"#c3c3c3\"/><stop offset=\"100%\" stop-color=\"#888888\"/></radialGradient><circle cx=\"0\" cy=\"0\" r=\"59.0\" fill=\"url(#x6g1)\" stroke=\"#000000\" stroke-width=\"10.4\"/></g>\n",
" <g id=\"x6a2\"><radialGradient id=\"x6g2\" cx=\".5\" cy=\".5\" fx=\".33\" fy=\".33\" r=\".66\"><stop offset=\"0%\" stop-color=\"#ff5555\"/><stop offset=\"100%\" stop-color=\"#cc0a0a\"/></radialGradient><circle cx=\"0\" cy=\"0\" r=\"52.9\" fill=\"url(#x6g2)\" stroke=\"#000000\" stroke-width=\"10.4\"/></g>\n",
" <g id=\"x6a8\"><radialGradient id=\"x6g8\" cx=\".5\" cy=\".5\" fx=\".33\" fy=\".33\" r=\".66\"><stop offset=\"0%\" stop-color=\"#ffffff\"/><stop offset=\"100%\" stop-color=\"#cccccc\"/></radialGradient><circle cx=\"0\" cy=\"0\" r=\"31.0\" fill=\"url(#x6g8)\" stroke=\"#000000\" stroke-width=\"10.4\"/></g>\n",
" </defs>\n",
" <use x=\"573.1\" y=\"411.9\" xlink:href=\"#x6a2\"/>\n",
" <line x1=\"617.7\" y1=\"395.1\" x2=\"694.9\" y2=\"366.0\" stroke=\"#000000\" stroke-width=\"26.0\" stroke-linecap=\"round\"/>\n",
" <line x1=\"543.7\" y1=\"374.4\" x2=\"462.4\" y2=\"270.6\" stroke=\"#000000\" stroke-width=\"26.0\" stroke-linecap=\"round\"/>\n",
" <line x1=\"298.4\" y1=\"480.1\" x2=\"404.8\" y2=\"134.5\" stroke=\"#b22222\" stroke-width=\"15.6\" stroke-linecap=\"round\"/>\n",
" <polygon points=\"420.9,82.3 424.7,140.6 385.0,128.4\" fill=\"#b22222\"/>\n",
" <text x=\"439.7\" y=\"43.0\" font-size=\"62.4\" fill=\"#b22222\" font-family=\"Arial,sans-serif\" text-anchor=\"middle\" font-weight=\"bold\">μ</text>\n",
" <use x=\"721.0\" y=\"356.2\" xlink:href=\"#x6a8\"/>\n",
" <use x=\"429.7\" y=\"228.8\" xlink:href=\"#x6a1\"/>\n",
" <line x1=\"379.3\" y1=\"245.5\" x2=\"245.9\" y2=\"289.6\" stroke=\"#000000\" stroke-width=\"26.0\" stroke-linecap=\"round\"/>\n",
" <use x=\"195.5\" y=\"306.3\" xlink:href=\"#x6a0\"/>\n",
"</svg>"
],
"text/plain": [
"<xyzrender.api.SVGResult at 0x7e746c0764e0>"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from xyzrender import load, render\n",
"\n",
"etoh = load(\"structures/ethanol.xyz\")\n",
"vec = {\n",
" \"anchor\": \"center\",\n",
" \"vectors\": [\n",
" {\n",
" \"origin\": \"com\",\n",
" \"vector\": [1.0320170291976951, -0.042708195030485986, -1.332397645862797],\n",
" \"color\": \"firebrick\",\n",
" \"label\": \"μ\",\n",
" }\n",
" ],\n",
"}\n",
"render(etoh, vectors=vec, vector_scale=1.5)"
]
"outputs": [],
"source": "from xyzrender import load, render\n\netoh = load(\"structures/ethanol.xyz\")\nvec = {\n \"anchor\": \"center\",\n \"vectors\": [\n {\n \"origin\": \"com\",\n \"vector\": [1.0320170291976951, -0.042708195030485986, -1.332397645862797],\n \"color\": \"firebrick\",\n \"label\": \"μ\",\n }\n ],\n}\nrender(etoh, vector=vec, vector_scale=1.5)"
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": null,
"id": "4fa885ba",
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" viewBox=\"0 0 800 554\" width=\"500\" height=\"auto\">\n",
" <rect width=\"100%\" height=\"100%\" fill=\"#ffffff\"/>\n",
" <defs>\n",
" <g id=\"x9a0\"><radialGradient id=\"x9g0\" cx=\".5\" cy=\".5\" fx=\".33\" fy=\".33\" r=\".66\"><stop offset=\"0%\" stop-color=\"#c3c3c3\"/><stop offset=\"100%\" stop-color=\"#888888\"/></radialGradient><circle cx=\"0\" cy=\"0\" r=\"59.0\" fill=\"url(#x9g0)\" stroke=\"#000000\" stroke-width=\"10.4\"/></g>\n",
" <g id=\"x9a1\"><radialGradient id=\"x9g1\" cx=\".5\" cy=\".5\" fx=\".33\" fy=\".33\" r=\".66\"><stop offset=\"0%\" stop-color=\"#c3c3c3\"/><stop offset=\"100%\" stop-color=\"#888888\"/></radialGradient><circle cx=\"0\" cy=\"0\" r=\"59.0\" fill=\"url(#x9g1)\" stroke=\"#000000\" stroke-width=\"10.4\"/></g>\n",
" <g id=\"x9a2\"><radialGradient id=\"x9g2\" cx=\".5\" cy=\".5\" fx=\".33\" fy=\".33\" r=\".66\"><stop offset=\"0%\" stop-color=\"#ff5555\"/><stop offset=\"100%\" stop-color=\"#cc0a0a\"/></radialGradient><circle cx=\"0\" cy=\"0\" r=\"52.9\" fill=\"url(#x9g2)\" stroke=\"#000000\" stroke-width=\"10.4\"/></g>\n",
" <g id=\"x9a3\"><radialGradient id=\"x9g3\" cx=\".5\" cy=\".5\" fx=\".33\" fy=\".33\" r=\".66\"><stop offset=\"0%\" stop-color=\"#ffffff\"/><stop offset=\"100%\" stop-color=\"#d6d6d6\"/></radialGradient><circle cx=\"0\" cy=\"0\" r=\"31.0\" fill=\"url(#x9g3)\" stroke=\"#494949\" stroke-width=\"10.4\"/></g>\n",
" <g id=\"x9a4\"><radialGradient id=\"x9g4\" cx=\".5\" cy=\".5\" fx=\".33\" fy=\".33\" r=\".66\"><stop offset=\"0%\" stop-color=\"#ffffff\"/><stop offset=\"100%\" stop-color=\"#cccccc\"/></radialGradient><circle cx=\"0\" cy=\"0\" r=\"31.0\" fill=\"url(#x9g4)\" stroke=\"#000000\" stroke-width=\"10.4\"/></g>\n",
" <g id=\"x9a5\"><radialGradient id=\"x9g5\" cx=\".5\" cy=\".5\" fx=\".33\" fy=\".33\" r=\".66\"><stop offset=\"0%\" stop-color=\"#ffffff\"/><stop offset=\"100%\" stop-color=\"#cccccc\"/></radialGradient><circle cx=\"0\" cy=\"0\" r=\"31.0\" fill=\"url(#x9g5)\" stroke=\"#000000\" stroke-width=\"10.4\"/></g>\n",
" <g id=\"x9a6\"><radialGradient id=\"x9g6\" cx=\".5\" cy=\".5\" fx=\".33\" fy=\".33\" r=\".66\"><stop offset=\"0%\" stop-color=\"#ffffff\"/><stop offset=\"100%\" stop-color=\"#d5d5d5\"/></radialGradient><circle cx=\"0\" cy=\"0\" r=\"31.0\" fill=\"url(#x9g6)\" stroke=\"#414141\" stroke-width=\"10.4\"/></g>\n",
" <g id=\"x9a7\"><radialGradient id=\"x9g7\" cx=\".5\" cy=\".5\" fx=\".33\" fy=\".33\" r=\".66\"><stop offset=\"0%\" stop-color=\"#ffffff\"/><stop offset=\"100%\" stop-color=\"#cccccc\"/></radialGradient><circle cx=\"0\" cy=\"0\" r=\"31.0\" fill=\"url(#x9g7)\" stroke=\"#000000\" stroke-width=\"10.4\"/></g>\n",
" <g id=\"x9a8\"><radialGradient id=\"x9g8\" cx=\".5\" cy=\".5\" fx=\".33\" fy=\".33\" r=\".66\"><stop offset=\"0%\" stop-color=\"#ffffff\"/><stop offset=\"100%\" stop-color=\"#cccccc\"/></radialGradient><circle cx=\"0\" cy=\"0\" r=\"31.0\" fill=\"url(#x9g8)\" stroke=\"#000000\" stroke-width=\"10.4\"/></g>\n",
" </defs>\n",
" <use x=\"159.2\" y=\"352.5\" xlink:href=\"#x9a3\"/>\n",
" <line x1=\"164.8\" y1=\"338.7\" x2=\"184.9\" y2=\"288.8\" stroke=\"#0a0a0a\" stroke-width=\"26.0\" stroke-linecap=\"round\"/>\n",
" <use x=\"458.2\" y=\"80.5\" xlink:href=\"#x9a6\"/>\n",
" <line x1=\"453.8\" y1=\"96.6\" x2=\"438.1\" y2=\"154.4\" stroke=\"#090909\" stroke-width=\"26.0\" stroke-linecap=\"round\"/>\n",
" <line x1=\"426.4\" y1=\"534.1\" x2=\"683.6\" y2=\"243.0\" stroke=\"#b22222\" stroke-width=\"15.6\" stroke-linecap=\"round\"/>\n",
" <use x=\"573.1\" y=\"368.1\" xlink:href=\"#x9a2\"/>\n",
" <line x1=\"617.7\" y1=\"351.3\" x2=\"694.9\" y2=\"322.3\" stroke=\"#000000\" stroke-width=\"26.0\" stroke-linecap=\"round\"/>\n",
" <line x1=\"543.7\" y1=\"330.6\" x2=\"462.4\" y2=\"226.8\" stroke=\"#000000\" stroke-width=\"26.0\" stroke-linecap=\"round\"/>\n",
" <line x1=\"241.1\" y1=\"276.3\" x2=\"426.3\" y2=\"215.6\" stroke=\"#4682b4\" stroke-width=\"15.6\" stroke-linecap=\"round\"/>\n",
" <use x=\"721.0\" y=\"312.4\" xlink:href=\"#x9a8\"/>\n",
" <line x1=\"333.5\" y1=\"293.4\" x2=\"489.6\" y2=\"117.6\" stroke=\"#b22222\" stroke-width=\"15.6\" stroke-linecap=\"round\"/>\n",
" <use x=\"429.7\" y=\"185.1\" xlink:href=\"#x9a1\"/>\n",
" <line x1=\"379.3\" y1=\"201.7\" x2=\"245.9\" y2=\"245.8\" stroke=\"#000000\" stroke-width=\"26.0\" stroke-linecap=\"round\"/>\n",
" <line x1=\"436.1\" y1=\"154.1\" x2=\"448.5\" y2=\"95.2\" stroke=\"#000000\" stroke-width=\"26.0\" stroke-linecap=\"round\"/>\n",
" <line x1=\"222.9\" y1=\"190.8\" x2=\"187.5\" y2=\"283.2\" stroke=\"#b22222\" stroke-width=\"15.6\" stroke-linecap=\"round\"/>\n",
" <polygon points=\"168.0,334.2 168.1,275.8 206.9,290.7\" fill=\"#b22222\"/>\n",
" <use x=\"195.5\" y=\"262.5\" xlink:href=\"#x9a0\"/>\n",
" <line x1=\"161.2\" y1=\"222.0\" x2=\"97.0\" y2=\"146.3\" stroke=\"#000000\" stroke-width=\"26.0\" stroke-linecap=\"round\"/>\n",
" <line x1=\"187.7\" y1=\"294.9\" x2=\"173.3\" y2=\"354.9\" stroke=\"#000000\" stroke-width=\"26.0\" stroke-linecap=\"round\"/>\n",
" <use x=\"79.0\" y=\"125.0\" xlink:href=\"#x9a5\"/>\n",
" <use x=\"169.2\" y=\"372.0\" xlink:href=\"#x9a4\"/>\n",
" <use x=\"451.9\" y=\"78.9\" xlink:href=\"#x9a7\"/>\n",
" <polygon points=\"525.8,76.7 505.1,131.3 474.1,103.8\" fill=\"#b22222\"/>\n",
" <polygon points=\"719.8,202.1 699.2,256.8 668.1,229.3\" fill=\"#b22222\"/>\n",
" <polygon points=\"478.2,198.6 432.8,235.3 419.8,195.9\" fill=\"#4682b4\"/>\n",
" <text x=\"538.9\" y=\"200.5\" font-size=\"62.4\" fill=\"#4682b4\" font-family=\"Arial,sans-serif\" text-anchor=\"middle\" font-weight=\"bold\">E</text>\n",
"</svg>"
],
"text/plain": [
"<xyzrender.api.SVGResult at 0x7e74403ee780>"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"render(etoh, hy=True, vectors=\"structures/ethanol_forces_efield.json\", vector_scale=2)"
]
"outputs": [],
"source": "render(etoh, hy=True, vector=\"structures/ethanol_forces_efield.json\", vector_scale=2)"
},
{
"cell_type": "markdown",
Expand Down Expand Up @@ -3681,4 +3578,4 @@
},
"nbformat": 4,
"nbformat_minor": 5
}
}
4 changes: 2 additions & 2 deletions examples/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ xyzrender "$DIR/bimp.out" -o "$IMG/bimp_ts_nci.svg" --ts --gif-trj --vdw 84-169
xyzrender "$DIR/bimp.out" -o "$IMG/bimp_ts_nci.svg" --gif-ts --gif-rot --vdw 84-169 --nci -go "$IMG/bimp_nci_ts.gif"

echo "=== Vector arrows ==="
xyzrender "$DIR/ethanol.xyz" --vectors "$DIR/ethanol_dip.json" -o "$IMG/ethanol_dip.svg" --gif-rot -go "$IMG/ethanol_dip.gif" # dipole at center of mass, with rotation
xyzrender "$DIR/ethanol.xyz" --hy --vectors "$DIR/ethanol_forces_efield.json" --vector-scale 1.5 -o "$IMG/ethanol_forces_efield.svg" -go "$IMG/ethanol_forces_efield.gif" --gif-rot # per-atom forces, with rotation
xyzrender "$DIR/ethanol.xyz" --vector "$DIR/ethanol_dip.json" -o "$IMG/ethanol_dip.svg" --gif-rot -go "$IMG/ethanol_dip.gif" # dipole at center of mass, with rotation
xyzrender "$DIR/ethanol.xyz" --hy --vector "$DIR/ethanol_forces_efield.json" --vector-scale 1.5 -o "$IMG/ethanol_forces_efield.svg" -go "$IMG/ethanol_forces_efield.gif" --gif-rot # per-atom forces, with rotation

echo "=== Crystal / unit cell ==="
xyzrender "$DIR/caffeine_cell.xyz" --cell -o "$IMG/caffeine_cell.svg" --no-orient --gif-rot -go "$IMG/caffeine_cell.gif"
Expand Down
Loading
Loading