First steps
[1]:
import sisl
# We define the root directory where our files are
siesta_files = sisl._environ.get_environ_variable("SISL_FILES_TESTS") / "sisl" / "io" / "siesta"
Activating the viz framework
The first thing you will need to do in order to use plots is to import sisl.viz
:
[2]:
import sisl.viz
This will load the appropiate things into sisl to use the visualization tools. You can also control the loading of the framework with an environment variable:
SISL_VIZ_AUTOLOAD=True
will load the framework on import sisl
, so you won’t need to explicitly import it.
Note
If you use sisl to run high performance calculations where you initialize sisl frequently it’s better to have the autoloading turned off (default), as it might introduce an overhead.
Now that the framework has been loaded, we can start plotting!
Your first plots
The most straightforward way to plot things in sisl is to call their plot
method. For example if we have the path to a bands file we can call plot:
[3]:
sisl.get_sile(siesta_files / "SrTiO3.bands").plot()
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
Cell In[3], line 1
----> 1 sisl.get_sile(siesta_files / "SrTiO3.bands").plot()
File ~/checkouts/readthedocs.org/user_builds/sisl/conda/v0.14.2/lib/python3.12/site-packages/sisl/viz/_plotables.py:53, in ObjectPlotHandler.__call__(self, *args, **kwargs)
51 if self._default is None:
52 raise TypeError(f"No default plotting function has been defined for {self._obj.__class__.__name__}.")
---> 53 return getattr(self, self._default)(*args, **kwargs)
File ~/checkouts/readthedocs.org/user_builds/sisl/conda/v0.14.2/lib/python3.12/site-packages/sisl/_dispatcher.py:49, in AbstractDispatch.__call__(self, *args, **kwargs)
48 def __call__(self, *args, **kwargs):
---> 49 return self.dispatch(*args, **kwargs)
File ~/checkouts/readthedocs.org/user_builds/sisl/conda/v0.14.2/lib/python3.12/site-packages/sisl/viz/_plotables.py:61, in PlotDispatch.dispatch(self, *args, **kwargs)
59 def dispatch(self, *args, **kwargs):
60 """Runs the plotting function by passing the object instance to it."""
---> 61 return self._plot(self._obj, *args, **kwargs)
File ~/checkouts/readthedocs.org/user_builds/sisl/conda/v0.14.2/lib/python3.12/site-packages/sisl/viz/_plotables.py:270, in register_data_source.<locals>._plot(obj, __params_info, __signature, *args, **kwargs)
267 if k not in data_kwargs:
268 data_kwargs[k] = v
--> 270 data = data_source_cls.new(obj, *args, **data_kwargs)
272 plot_kwargs = bound.arguments.pop(params_info['plot_var_kwarg'], {})
274 return plot_cls(**{setting_key: data, **bound.arguments, **plot_kwargs})
File ~/checkouts/readthedocs.org/user_builds/sisl/conda/v0.14.2/lib/python3.12/functools.py:946, in singledispatchmethod.__get__.<locals>._method(*args, **kwargs)
944 def _method(*args, **kwargs):
945 method = self.dispatcher.dispatch(args[0].__class__)
--> 946 return method.__get__(obj, cls)(*args, **kwargs)
File ~/checkouts/readthedocs.org/user_builds/sisl/conda/v0.14.2/lib/python3.12/site-packages/sisl/viz/data/bands.py:274, in BandsData.from_siesta_bands(cls, bands_file)
269 @new.register
270 @classmethod
271 def from_siesta_bands(cls, bands_file: bandsSileSiesta):
272 """Gets the bands data from a SIESTA .bands file"""
--> 274 bands_data = bands_file.read_data(as_dataarray=True)
275 bands_data.k.attrs['axis'] = {
276 'tickvals': bands_data.attrs.pop('ticks'),
277 'ticktext': bands_data.attrs.pop('ticklabels')
278 }
280 return cls.new(bands_data)
File ~/checkouts/readthedocs.org/user_builds/sisl/conda/v0.14.2/lib/python3.12/site-packages/sisl/io/sile.py:661, in sile_fh_open.<locals>._wrapper.<locals>.pre_open(self, *args, **kwargs)
659 if hasattr(self, "fh"):
660 return func(self, *args, **kwargs)
--> 661 with self:
662 reset(self)
663 return func(self, *args, **kwargs)
File ~/checkouts/readthedocs.org/user_builds/sisl/conda/v0.14.2/lib/python3.12/site-packages/sisl/io/sile.py:795, in Sile.__enter__(self)
793 def __enter__(self):
794 """ Opens the output file and returns it self """
--> 795 self._open()
796 return self
File ~/checkouts/readthedocs.org/user_builds/sisl/conda/v0.14.2/lib/python3.12/site-packages/sisl/io/sile.py:786, in Sile._open(self)
784 self.fh = gzip.open(str(self.file), mode=self._mode)
785 else:
--> 786 self.fh = self.file.open(self._mode)
788 # the file should restart the file-read (as per instructed)
789 self._line = 0
File ~/checkouts/readthedocs.org/user_builds/sisl/conda/v0.14.2/lib/python3.12/pathlib.py:1014, in Path.open(self, mode, buffering, encoding, errors, newline)
1012 if "b" not in mode:
1013 encoding = io.text_encoding(encoding)
-> 1014 return io.open(self, mode, buffering, encoding, errors, newline)
FileNotFoundError: [Errno 2] No such file or directory: '_THIS_DIRECTORY_DOES_NOT_EXIST_/sisl/io/siesta/SrTiO3.bands'
You can pass arguments to the plotting function:
[4]:
rho_file = sisl.get_sile(siesta_files / "SrTiO3.RHO")
rho_file.plot(axes="xy", nsc=[2,1,1], smooth=True)
---------------------------------------------------------------------------
SileError Traceback (most recent call last)
Cell In[4], line 2
1 rho_file = sisl.get_sile(siesta_files / "SrTiO3.RHO")
----> 2 rho_file.plot(axes="xy", nsc=[2,1,1], smooth=True)
File ~/checkouts/readthedocs.org/user_builds/sisl/conda/v0.14.2/lib/python3.12/site-packages/sisl/viz/_plotables.py:53, in ObjectPlotHandler.__call__(self, *args, **kwargs)
51 if self._default is None:
52 raise TypeError(f"No default plotting function has been defined for {self._obj.__class__.__name__}.")
---> 53 return getattr(self, self._default)(*args, **kwargs)
File ~/checkouts/readthedocs.org/user_builds/sisl/conda/v0.14.2/lib/python3.12/site-packages/sisl/_dispatcher.py:49, in AbstractDispatch.__call__(self, *args, **kwargs)
48 def __call__(self, *args, **kwargs):
---> 49 return self.dispatch(*args, **kwargs)
File ~/checkouts/readthedocs.org/user_builds/sisl/conda/v0.14.2/lib/python3.12/site-packages/sisl/viz/_plotables.py:61, in PlotDispatch.dispatch(self, *args, **kwargs)
59 def dispatch(self, *args, **kwargs):
60 """Runs the plotting function by passing the object instance to it."""
---> 61 return self._plot(self._obj, *args, **kwargs)
File ~/checkouts/readthedocs.org/user_builds/sisl/conda/v0.14.2/lib/python3.12/site-packages/sisl/viz/_plotables.py:359, in register_sile_method.<locals>._plot(obj, *args, **kwargs)
356 except:
357 raise TypeError(f"Error while parsing arguments to create the call {method}")
--> 359 data = func(obj, *args, **data_kwargs)
361 plot_kwargs = bound.arguments.pop(params_info['plot_var_kwarg'], {})
363 return plot_cls(**{setting_key: data, **bound.arguments, **plot_kwargs})
File ~/checkouts/readthedocs.org/user_builds/sisl/conda/v0.14.2/lib/python3.12/site-packages/sisl/io/siesta/binaries.py:1736, in _gridSileSiesta.read_grid(self, index, dtype, *args, **kwargs)
1734 index = kwargs.get("spin", index)
1735 # Read the sizes and cell
-> 1736 nspin, mesh = self.read_grid_size()
1737 lattice = self.read_lattice()
1738 grid = _siesta.read_grid(self.file, nspin, mesh[0], mesh[1], mesh[2])
File ~/checkouts/readthedocs.org/user_builds/sisl/conda/v0.14.2/lib/python3.12/site-packages/sisl/io/siesta/binaries.py:1716, in _gridSileSiesta.read_grid_size(self)
1714 # Read the sizes
1715 nspin, mesh = _siesta.read_grid_sizes(self.file)
-> 1716 self._fortran_check("read_grid_size", "could not read grid sizes.")
1717 return nspin, mesh
File ~/checkouts/readthedocs.org/user_builds/sisl/conda/v0.14.2/lib/python3.12/site-packages/sisl/io/siesta/sile.py:50, in SileBinSiesta._fortran_check(self, method, message, ret_msg)
48 msg = f'{self!s}.{method} {message} (ierr={ierr})'
49 if not ret_msg:
---> 50 raise SileError(msg)
51 if ret_msg:
52 return msg
SileError: rhoSileSiesta(SrTiO3.RHO, base=_THIS_DIRECTORY_DOES_NOT_EXIST_/sisl/io/siesta).read_grid_size could not read grid sizes. (ierr=2)
Some objects can be plotted in different ways, and just calling plot
will do it in the default way. You can however choose which plot you want from the available representations. For example, out of a PDOS file you can plot the PDOS (the default):
[5]:
pdos_file = sisl.get_sile(siesta_files / "SrTiO3.PDOS")
pdos_file.plot(groups=[{"species": "O", "name": "O"}, {"species": "Ti", "name": "Ti"}])
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
Cell In[5], line 3
1 pdos_file = sisl.get_sile(siesta_files / "SrTiO3.PDOS")
----> 3 pdos_file.plot(groups=[{"species": "O", "name": "O"}, {"species": "Ti", "name": "Ti"}])
File ~/checkouts/readthedocs.org/user_builds/sisl/conda/v0.14.2/lib/python3.12/site-packages/sisl/viz/_plotables.py:53, in ObjectPlotHandler.__call__(self, *args, **kwargs)
51 if self._default is None:
52 raise TypeError(f"No default plotting function has been defined for {self._obj.__class__.__name__}.")
---> 53 return getattr(self, self._default)(*args, **kwargs)
File ~/checkouts/readthedocs.org/user_builds/sisl/conda/v0.14.2/lib/python3.12/site-packages/sisl/_dispatcher.py:49, in AbstractDispatch.__call__(self, *args, **kwargs)
48 def __call__(self, *args, **kwargs):
---> 49 return self.dispatch(*args, **kwargs)
File ~/checkouts/readthedocs.org/user_builds/sisl/conda/v0.14.2/lib/python3.12/site-packages/sisl/viz/_plotables.py:61, in PlotDispatch.dispatch(self, *args, **kwargs)
59 def dispatch(self, *args, **kwargs):
60 """Runs the plotting function by passing the object instance to it."""
---> 61 return self._plot(self._obj, *args, **kwargs)
File ~/checkouts/readthedocs.org/user_builds/sisl/conda/v0.14.2/lib/python3.12/site-packages/sisl/viz/_plotables.py:270, in register_data_source.<locals>._plot(obj, __params_info, __signature, *args, **kwargs)
267 if k not in data_kwargs:
268 data_kwargs[k] = v
--> 270 data = data_source_cls.new(obj, *args, **data_kwargs)
272 plot_kwargs = bound.arguments.pop(params_info['plot_var_kwarg'], {})
274 return plot_cls(**{setting_key: data, **bound.arguments, **plot_kwargs})
File ~/checkouts/readthedocs.org/user_builds/sisl/conda/v0.14.2/lib/python3.12/functools.py:946, in singledispatchmethod.__get__.<locals>._method(*args, **kwargs)
944 def _method(*args, **kwargs):
945 method = self.dispatcher.dispatch(args[0].__class__)
--> 946 return method.__get__(obj, cls)(*args, **kwargs)
File ~/checkouts/readthedocs.org/user_builds/sisl/conda/v0.14.2/lib/python3.12/site-packages/sisl/viz/data/pdos.py:244, in PDOSData.from_siesta_pdos(cls, pdos_file)
242 """Gets the PDOS from a SIESTA PDOS file"""
243 # Get the info from the .PDOS file
--> 244 geometry, E, PDOS = pdos_file.read_data()
246 return cls.new(PDOS, geometry, E)
File ~/checkouts/readthedocs.org/user_builds/sisl/conda/v0.14.2/lib/python3.12/site-packages/sisl/io/sile.py:648, in sile_fh_open.<locals>._wrapper.<locals>.pre_open(self, *args, **kwargs)
646 if hasattr(self, "fh"):
647 def _reset(self): pass
--> 648 with self:
649 # REMARK this requires the __enter__ to seek(0)
650 # for the file, and currently it does
651 _reset(self)
652 return func(self, *args, **kwargs)
File ~/checkouts/readthedocs.org/user_builds/sisl/conda/v0.14.2/lib/python3.12/site-packages/sisl/io/sile.py:795, in Sile.__enter__(self)
793 def __enter__(self):
794 """ Opens the output file and returns it self """
--> 795 self._open()
796 return self
File ~/checkouts/readthedocs.org/user_builds/sisl/conda/v0.14.2/lib/python3.12/site-packages/sisl/io/sile.py:786, in Sile._open(self)
784 self.fh = gzip.open(str(self.file), mode=self._mode)
785 else:
--> 786 self.fh = self.file.open(self._mode)
788 # the file should restart the file-read (as per instructed)
789 self._line = 0
File ~/checkouts/readthedocs.org/user_builds/sisl/conda/v0.14.2/lib/python3.12/pathlib.py:1014, in Path.open(self, mode, buffering, encoding, errors, newline)
1012 if "b" not in mode:
1013 encoding = io.text_encoding(encoding)
-> 1014 return io.open(self, mode, buffering, encoding, errors, newline)
FileNotFoundError: [Errno 2] No such file or directory: '_THIS_DIRECTORY_DOES_NOT_EXIST_/sisl/io/siesta/SrTiO3.PDOS'
or the geometry (not the default, you need to specify it):
[6]:
pdos_file.plot.geometry(atoms_scale=0.7)
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
Cell In[6], line 1
----> 1 pdos_file.plot.geometry(atoms_scale=0.7)
File ~/checkouts/readthedocs.org/user_builds/sisl/conda/v0.14.2/lib/python3.12/site-packages/sisl/_dispatcher.py:49, in AbstractDispatch.__call__(self, *args, **kwargs)
48 def __call__(self, *args, **kwargs):
---> 49 return self.dispatch(*args, **kwargs)
File ~/checkouts/readthedocs.org/user_builds/sisl/conda/v0.14.2/lib/python3.12/site-packages/sisl/viz/_plotables.py:61, in PlotDispatch.dispatch(self, *args, **kwargs)
59 def dispatch(self, *args, **kwargs):
60 """Runs the plotting function by passing the object instance to it."""
---> 61 return self._plot(self._obj, *args, **kwargs)
File ~/checkouts/readthedocs.org/user_builds/sisl/conda/v0.14.2/lib/python3.12/site-packages/sisl/viz/_plotables.py:359, in register_sile_method.<locals>._plot(obj, *args, **kwargs)
356 except:
357 raise TypeError(f"Error while parsing arguments to create the call {method}")
--> 359 data = func(obj, *args, **data_kwargs)
361 plot_kwargs = bound.arguments.pop(params_info['plot_var_kwarg'], {})
363 return plot_cls(**{setting_key: data, **bound.arguments, **plot_kwargs})
File ~/checkouts/readthedocs.org/user_builds/sisl/conda/v0.14.2/lib/python3.12/site-packages/sisl/io/siesta/pdos.py:41, in pdosSileSiesta.read_geometry(self)
39 def read_geometry(self):
40 """ Read the geometry with coordinates and correct orbital counts """
---> 41 return self.read_data()[0]
File ~/checkouts/readthedocs.org/user_builds/sisl/conda/v0.14.2/lib/python3.12/site-packages/sisl/io/sile.py:648, in sile_fh_open.<locals>._wrapper.<locals>.pre_open(self, *args, **kwargs)
646 if hasattr(self, "fh"):
647 def _reset(self): pass
--> 648 with self:
649 # REMARK this requires the __enter__ to seek(0)
650 # for the file, and currently it does
651 _reset(self)
652 return func(self, *args, **kwargs)
File ~/checkouts/readthedocs.org/user_builds/sisl/conda/v0.14.2/lib/python3.12/site-packages/sisl/io/sile.py:795, in Sile.__enter__(self)
793 def __enter__(self):
794 """ Opens the output file and returns it self """
--> 795 self._open()
796 return self
File ~/checkouts/readthedocs.org/user_builds/sisl/conda/v0.14.2/lib/python3.12/site-packages/sisl/io/sile.py:786, in Sile._open(self)
784 self.fh = gzip.open(str(self.file), mode=self._mode)
785 else:
--> 786 self.fh = self.file.open(self._mode)
788 # the file should restart the file-read (as per instructed)
789 self._line = 0
File ~/checkouts/readthedocs.org/user_builds/sisl/conda/v0.14.2/lib/python3.12/pathlib.py:1014, in Path.open(self, mode, buffering, encoding, errors, newline)
1012 if "b" not in mode:
1013 encoding = io.text_encoding(encoding)
-> 1014 return io.open(self, mode, buffering, encoding, errors, newline)
FileNotFoundError: [Errno 2] No such file or directory: '_THIS_DIRECTORY_DOES_NOT_EXIST_/sisl/io/siesta/SrTiO3.PDOS'
Updating your plots
When you call .plot()
, you receive a Plot
object:
[7]:
pdos_plot = pdos_file.plot()
type(pdos_plot)
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
Cell In[7], line 1
----> 1 pdos_plot = pdos_file.plot()
2 type(pdos_plot)
File ~/checkouts/readthedocs.org/user_builds/sisl/conda/v0.14.2/lib/python3.12/site-packages/sisl/viz/_plotables.py:53, in ObjectPlotHandler.__call__(self, *args, **kwargs)
51 if self._default is None:
52 raise TypeError(f"No default plotting function has been defined for {self._obj.__class__.__name__}.")
---> 53 return getattr(self, self._default)(*args, **kwargs)
File ~/checkouts/readthedocs.org/user_builds/sisl/conda/v0.14.2/lib/python3.12/site-packages/sisl/_dispatcher.py:49, in AbstractDispatch.__call__(self, *args, **kwargs)
48 def __call__(self, *args, **kwargs):
---> 49 return self.dispatch(*args, **kwargs)
File ~/checkouts/readthedocs.org/user_builds/sisl/conda/v0.14.2/lib/python3.12/site-packages/sisl/viz/_plotables.py:61, in PlotDispatch.dispatch(self, *args, **kwargs)
59 def dispatch(self, *args, **kwargs):
60 """Runs the plotting function by passing the object instance to it."""
---> 61 return self._plot(self._obj, *args, **kwargs)
File ~/checkouts/readthedocs.org/user_builds/sisl/conda/v0.14.2/lib/python3.12/site-packages/sisl/viz/_plotables.py:270, in register_data_source.<locals>._plot(obj, __params_info, __signature, *args, **kwargs)
267 if k not in data_kwargs:
268 data_kwargs[k] = v
--> 270 data = data_source_cls.new(obj, *args, **data_kwargs)
272 plot_kwargs = bound.arguments.pop(params_info['plot_var_kwarg'], {})
274 return plot_cls(**{setting_key: data, **bound.arguments, **plot_kwargs})
File ~/checkouts/readthedocs.org/user_builds/sisl/conda/v0.14.2/lib/python3.12/functools.py:946, in singledispatchmethod.__get__.<locals>._method(*args, **kwargs)
944 def _method(*args, **kwargs):
945 method = self.dispatcher.dispatch(args[0].__class__)
--> 946 return method.__get__(obj, cls)(*args, **kwargs)
File ~/checkouts/readthedocs.org/user_builds/sisl/conda/v0.14.2/lib/python3.12/site-packages/sisl/viz/data/pdos.py:244, in PDOSData.from_siesta_pdos(cls, pdos_file)
242 """Gets the PDOS from a SIESTA PDOS file"""
243 # Get the info from the .PDOS file
--> 244 geometry, E, PDOS = pdos_file.read_data()
246 return cls.new(PDOS, geometry, E)
File ~/checkouts/readthedocs.org/user_builds/sisl/conda/v0.14.2/lib/python3.12/site-packages/sisl/io/sile.py:648, in sile_fh_open.<locals>._wrapper.<locals>.pre_open(self, *args, **kwargs)
646 if hasattr(self, "fh"):
647 def _reset(self): pass
--> 648 with self:
649 # REMARK this requires the __enter__ to seek(0)
650 # for the file, and currently it does
651 _reset(self)
652 return func(self, *args, **kwargs)
File ~/checkouts/readthedocs.org/user_builds/sisl/conda/v0.14.2/lib/python3.12/site-packages/sisl/io/sile.py:795, in Sile.__enter__(self)
793 def __enter__(self):
794 """ Opens the output file and returns it self """
--> 795 self._open()
796 return self
File ~/checkouts/readthedocs.org/user_builds/sisl/conda/v0.14.2/lib/python3.12/site-packages/sisl/io/sile.py:786, in Sile._open(self)
784 self.fh = gzip.open(str(self.file), mode=self._mode)
785 else:
--> 786 self.fh = self.file.open(self._mode)
788 # the file should restart the file-read (as per instructed)
789 self._line = 0
File ~/checkouts/readthedocs.org/user_builds/sisl/conda/v0.14.2/lib/python3.12/pathlib.py:1014, in Path.open(self, mode, buffering, encoding, errors, newline)
1012 if "b" not in mode:
1013 encoding = io.text_encoding(encoding)
-> 1014 return io.open(self, mode, buffering, encoding, errors, newline)
FileNotFoundError: [Errno 2] No such file or directory: '_THIS_DIRECTORY_DOES_NOT_EXIST_/sisl/io/siesta/SrTiO3.PDOS'
Plot
objects are a kind of Workflow
. You can check the sisl.nodes
documentation to understand what exactly this means. But long story short, this means that the computation is split in multiple nodes, as you can see in the following diagram:
[8]:
pdos_plot.network.visualize(notebook=True)
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
Cell In[8], line 1
----> 1 pdos_plot.network.visualize(notebook=True)
NameError: name 'pdos_plot' is not defined
With that knowledge, when you update the inputs of a plot, only the necessary parts are recalculated. In that way, you may avoid repeating expensive calculations or reading to files that no longer exist. Inputs are updated with update_inputs
:
[9]:
pdos_plot.update_inputs(Erange=[-3, 3])
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
Cell In[9], line 1
----> 1 pdos_plot.update_inputs(Erange=[-3, 3])
NameError: name 'pdos_plot' is not defined
Some inputs are a bit cumbersome to write by hand, and therefore along your journey you’ll find that plots have some helper methods to modify inputs much faster. For example, PdosPlot
has the split_DOS
method, which generates groups of orbitals for you.
[10]:
pdos_plot.split_DOS()
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
Cell In[10], line 1
----> 1 pdos_plot.split_DOS()
NameError: name 'pdos_plot' is not defined
Don’t worry!
Each plot class has its own dedicated notebook in the documentation to guide you through all the knobs that they have!
Different plotting backends
Hidden between all the inputs, you can find a very special input: backend
.
This input allows you to choose the plotting backend used to display a plot. If you don’t like the default one, just change it!
[11]:
pdos_plot.update_inputs(backend="matplotlib")
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
Cell In[11], line 1
----> 1 pdos_plot.update_inputs(backend="matplotlib")
NameError: name 'pdos_plot' is not defined
Let’s go back to the default one, plotly
.
[12]:
pdos_plot.update_inputs(backend="plotly")
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
Cell In[12], line 1
----> 1 pdos_plot.update_inputs(backend="plotly")
NameError: name 'pdos_plot' is not defined
Further customization
If you are a master of some backend, you’ll be happy to know that you can run any backend specific method on the plot. For example, plotly has a method called add_vline
that draws a vertical line:
[13]:
pdos_plot.add_vline(-1).add_vline(2)
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
Cell In[13], line 1
----> 1 pdos_plot.add_vline(-1).add_vline(2)
NameError: name 'pdos_plot' is not defined
In fact, if you need the raw figure for something, you can find it under the figure
attribute.
[14]:
type(pdos_plot.figure)
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
Cell In[14], line 1
----> 1 type(pdos_plot.figure)
NameError: name 'pdos_plot' is not defined
Discover more
This notebook has shown you the most basic features of the framework with the hope that you will be hooked into it :)
If it succeeded, we invite you to check the rest of the documentation. It only gets better from here!
This next cell is just to create the thumbnail for the notebook in the docs
[15]:
thumbnail_plot = rho_file.plot(axes="xy", nsc=[2,1,1], smooth=True)
if thumbnail_plot:
thumbnail_plot.show("png")
---------------------------------------------------------------------------
SileError Traceback (most recent call last)
Cell In[15], line 1
----> 1 thumbnail_plot = rho_file.plot(axes="xy", nsc=[2,1,1], smooth=True)
3 if thumbnail_plot:
4 thumbnail_plot.show("png")
File ~/checkouts/readthedocs.org/user_builds/sisl/conda/v0.14.2/lib/python3.12/site-packages/sisl/viz/_plotables.py:53, in ObjectPlotHandler.__call__(self, *args, **kwargs)
51 if self._default is None:
52 raise TypeError(f"No default plotting function has been defined for {self._obj.__class__.__name__}.")
---> 53 return getattr(self, self._default)(*args, **kwargs)
File ~/checkouts/readthedocs.org/user_builds/sisl/conda/v0.14.2/lib/python3.12/site-packages/sisl/_dispatcher.py:49, in AbstractDispatch.__call__(self, *args, **kwargs)
48 def __call__(self, *args, **kwargs):
---> 49 return self.dispatch(*args, **kwargs)
File ~/checkouts/readthedocs.org/user_builds/sisl/conda/v0.14.2/lib/python3.12/site-packages/sisl/viz/_plotables.py:61, in PlotDispatch.dispatch(self, *args, **kwargs)
59 def dispatch(self, *args, **kwargs):
60 """Runs the plotting function by passing the object instance to it."""
---> 61 return self._plot(self._obj, *args, **kwargs)
File ~/checkouts/readthedocs.org/user_builds/sisl/conda/v0.14.2/lib/python3.12/site-packages/sisl/viz/_plotables.py:359, in register_sile_method.<locals>._plot(obj, *args, **kwargs)
356 except:
357 raise TypeError(f"Error while parsing arguments to create the call {method}")
--> 359 data = func(obj, *args, **data_kwargs)
361 plot_kwargs = bound.arguments.pop(params_info['plot_var_kwarg'], {})
363 return plot_cls(**{setting_key: data, **bound.arguments, **plot_kwargs})
File ~/checkouts/readthedocs.org/user_builds/sisl/conda/v0.14.2/lib/python3.12/site-packages/sisl/io/siesta/binaries.py:1736, in _gridSileSiesta.read_grid(self, index, dtype, *args, **kwargs)
1734 index = kwargs.get("spin", index)
1735 # Read the sizes and cell
-> 1736 nspin, mesh = self.read_grid_size()
1737 lattice = self.read_lattice()
1738 grid = _siesta.read_grid(self.file, nspin, mesh[0], mesh[1], mesh[2])
File ~/checkouts/readthedocs.org/user_builds/sisl/conda/v0.14.2/lib/python3.12/site-packages/sisl/io/siesta/binaries.py:1716, in _gridSileSiesta.read_grid_size(self)
1714 # Read the sizes
1715 nspin, mesh = _siesta.read_grid_sizes(self.file)
-> 1716 self._fortran_check("read_grid_size", "could not read grid sizes.")
1717 return nspin, mesh
File ~/checkouts/readthedocs.org/user_builds/sisl/conda/v0.14.2/lib/python3.12/site-packages/sisl/io/siesta/sile.py:50, in SileBinSiesta._fortran_check(self, method, message, ret_msg)
48 msg = f'{self!s}.{method} {message} (ierr={ierr})'
49 if not ret_msg:
---> 50 raise SileError(msg)
51 if ret_msg:
52 return msg
SileError: rhoSileSiesta(SrTiO3.RHO, base=_THIS_DIRECTORY_DOES_NOT_EXIST_/sisl/io/siesta).read_grid_size could not read grid sizes. (ierr=2)
[ ]: