Skip to content

Commit 14a475e

Browse files
committed
Merge pull request #476 from pfebrer/viz_data_sources
Refactoring the viz module to a more modular design.
2 parents 95057b4 + bc1ea37 commit 14a475e

File tree

204 files changed

+13797
-20090
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

204 files changed

+13797
-20090
lines changed

docs/api/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ All methods and submodules are listed :ref:`here <genindex>` and
2525
default_geom
2626
physics
2727
mixing
28+
viz/index
2829
unit_constant
2930
utilities
3031

@@ -38,5 +39,4 @@ All methods and submodules are listed :ref:`here <genindex>` and
3839
:caption: Advanced usage
3940

4041
nodes
41-
viz/index
4242

docs/api/viz/index.rst

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,37 @@
44
Visualization
55
=============
66

7-
.. currentmodule:: sisl.viz
7+
.. module:: sisl.viz
88

9-
Visualizations of `sisl` objects and data.
9+
The visualization module contains tools to plot common visualizations, as well
10+
as to create custom visualizations that support multiple plotting backends
11+
automatically.
1012

13+
Plot classes
14+
-----------------
15+
16+
Plot classes are workflow classes that implement some specific plotting.
17+
18+
.. autosummary::
19+
:toctree: generated/
20+
21+
Plot
22+
BandsPlot
23+
FatbandsPlot
24+
GeometryPlot
25+
SitesPlot
26+
GridPlot
27+
WavefunctionPlot
28+
PdosPlot
29+
30+
Utilities
31+
---------
32+
33+
Utilities to build custom plots
1134

1235
.. autosummary::
13-
:toctree: generated/
14-
:recursive:
36+
:toctree: generated/
1537

38+
get_figure
39+
merge_plots
40+
Figure

docs/tutorials/tutorial_es_1.ipynb

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"import numpy as np\n",
1010
"from sisl import *\n",
1111
"import sisl.viz\n",
12+
"from sisl.viz import merge_plots\n",
1213
"import matplotlib.pyplot as plt\n",
1314
"%matplotlib inline"
1415
]
@@ -119,8 +120,8 @@
119120
"system = graphene.remove(index)\n",
120121
"graphene.plot(axes=\"xy\", atoms_style=[\n",
121122
" {\"opacity\": 0.5}, # Default style for all atoms\n",
122-
" {\"atoms\": indices, \"color\": \"black\", \"size\": 20, \"opacity\": 1}, # Styling for indices_close_to_center on top of defaults.\n",
123-
" {\"atoms\": index, \"color\": \"red\", \"size\": 10, \"opacity\": 1} # Styling for center_atom_index on top of defaults.\n",
123+
" {\"atoms\": indices, \"color\": \"black\", \"size\": 1.2, \"opacity\": 1}, # Styling for indices_close_to_center on top of defaults.\n",
124+
" {\"atoms\": index, \"color\": \"red\", \"size\": 1, \"opacity\": 1} # Styling for center_atom_index on top of defaults.\n",
124125
"])"
125126
]
126127
},
@@ -195,12 +196,13 @@
195196
"es = H.eigenstate()\n",
196197
"# Reduce the contained eigenstates to only 3 states around the Fermi-level\n",
197198
"es_fermi = es.sub(range(len(H) // 2 - 1, len(H) // 2 + 2))\n",
198-
"system.plot(\n",
199-
" subplots=\"atoms_style\", cols=3,\n",
200-
" axes=\"xy\", \n",
201-
" atoms_style=[{\"size\": n * 300, \"color\": c}\n",
202-
" for n, c in zip(es_fermi.norm2(sum=False), (\"red\", \"blue\", \"green\"))]\n",
203-
")"
199+
"\n",
200+
"plots = [\n",
201+
" system.plot(axes=\"xy\", atoms_style=[{\"size\": n * 20, \"color\": c}]) \n",
202+
" for n, c in zip(es_fermi.norm2(sum=False), (\"red\", \"blue\", \"green\"))\n",
203+
"]\n",
204+
"\n",
205+
"merge_plots(*plots, composite_method=\"subplots\", cols=3)"
204206
]
205207
},
206208
{
@@ -243,7 +245,7 @@
243245
"E = np.linspace(-1, -.5, 100)\n",
244246
"dE = E[1] - E[0]\n",
245247
"PDOS = es.PDOS(E).sum((0, 2)) * dE # perform integration\n",
246-
"system.plot(axes=\"xy\", atoms_style={\"size\": PDOS * 300})\n",
248+
"system.plot(axes=\"xy\", atoms_style={\"size\": PDOS * 15})\n",
247249
"#plt.scatter(system.xyz[:, 0], system.xyz[:, 1], 500 * PDOS);\n",
248250
"#plt.scatter(xyz_remove[0], xyz_remove[1], c='k', marker='*'); # mark the removed atom"
249251
]
@@ -274,8 +276,8 @@
274276
"source": [
275277
"band = BandStructure(H, [[0, 0, 0], [0, 0.5, 0], \n",
276278
" [1/3, 2/3, 0], [0, 0, 0]], 400, \n",
277-
" [r'$\\Gamma$', r'$M$', \n",
278-
" r'$K$', r'$\\Gamma$'])"
279+
" [r'Gamma', r'M', \n",
280+
" r'K', r'Gamma'])"
279281
]
280282
},
281283
{
@@ -479,7 +481,7 @@
479481
"metadata": {},
480482
"outputs": [],
481483
"source": [
482-
"grid.plot(axes=\"xy\", xaxis_range=(0, None))"
484+
"grid.plot(axes=\"xy\")"
483485
]
484486
},
485487
{
@@ -517,9 +519,9 @@
517519
"name": "python",
518520
"nbconvert_exporter": "python",
519521
"pygments_lexer": "ipython3",
520-
"version": "3.9.9"
522+
"version": "3.11.4"
521523
}
522524
},
523525
"nbformat": 4,
524-
"nbformat_minor": 2
526+
"nbformat_minor": 4
525527
}

docs/tutorials/tutorial_siesta_1.ipynb

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"import numpy as np\n",
1212
"from sisl import *\n",
1313
"import sisl.viz\n",
14+
"from sisl.viz import merge_plots\n",
1415
"from functools import partial\n",
1516
"import matplotlib.pyplot as plt\n",
1617
"%matplotlib inline"
@@ -234,16 +235,17 @@
234235
"# Find the index of the smallest positive eigenvalue\n",
235236
"idx_lumo = (es.eig > 0).nonzero()[0][0]\n",
236237
"es = es.sub([idx_lumo - 1, idx_lumo])\n",
237-
"h2o.plot(\n",
238-
" subplots=\"atoms_style\", cols=2,\n",
239-
" axes=\"xy\", \n",
240-
" atoms_style=[{\"size\": n * 30, \"color\": c}\n",
241-
" for n, c in zip(h2o.apply(es.norm2(sum=False),\n",
238+
"\n",
239+
"plots = [\n",
240+
" h2o.plot(axes=\"xy\", atoms_style={\"size\": n * 1.5, \"color\": c})\n",
241+
" for n, c in zip(h2o.apply(es.norm2(sum=False),\n",
242242
" np.sum,\n",
243243
" mapper=partial(h2o.a2o, all=True),\n",
244244
" axis=1),\n",
245-
" (\"red\", \"blue\", \"green\"))]\n",
246-
")"
245+
" (\"red\", \"blue\", \"green\"))\n",
246+
"]\n",
247+
"\n",
248+
"merge_plots(*plots, composite_method=\"subplots\", cols=2)"
247249
]
248250
},
249251
{
@@ -312,6 +314,13 @@
312314
"DM.density(diff)\n",
313315
"print('Real space integrated density difference: {:.3e}'.format(diff.grid.sum() * diff.dvolume))"
314316
]
317+
},
318+
{
319+
"cell_type": "code",
320+
"execution_count": null,
321+
"metadata": {},
322+
"outputs": [],
323+
"source": []
315324
}
316325
],
317326
"metadata": {
@@ -330,9 +339,9 @@
330339
"name": "python",
331340
"nbconvert_exporter": "python",
332341
"pygments_lexer": "ipython3",
333-
"version": "3.9.9"
342+
"version": "3.8.15"
334343
}
335344
},
336345
"nbformat": 4,
337-
"nbformat_minor": 2
346+
"nbformat_minor": 4
338347
}

docs/tutorials/tutorial_siesta_2.ipynb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,9 +363,9 @@
363363
"name": "python",
364364
"nbconvert_exporter": "python",
365365
"pygments_lexer": "ipython3",
366-
"version": "3.9.9"
366+
"version": "3.8.15"
367367
}
368368
},
369369
"nbformat": 4,
370-
"nbformat_minor": 2
370+
"nbformat_minor": 4
371371
}

0 commit comments

Comments
 (0)