ipynb download badge. Binder badge

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/stable/lib/python3.12/site-packages/sisl/viz/_plotables.py:56, in ObjectPlotHandler.__call__(self, *args, **kwargs)
     52 if self._default is None:
     53     raise TypeError(
     54         f"No default plotting function has been defined for {self._obj.__class__.__name__}."
     55     )
---> 56 return getattr(self, self._default)(*args, **kwargs)

File ~/checkouts/readthedocs.org/user_builds/sisl/conda/stable/lib/python3.12/site-packages/sisl/_dispatcher.py:65, in AbstractDispatch.__call__(self, *args, **kwargs)
     63 def __call__(self, *args, **kwargs):
     64     _log.debug(f"call {self.__class__.__name__}{args}", extra={"obj": self})
---> 65     return self.dispatch(*args, **kwargs)

File ~/checkouts/readthedocs.org/user_builds/sisl/conda/stable/lib/python3.12/site-packages/sisl/viz/_plotables.py:64, in PlotDispatch.dispatch(self, *args, **kwargs)
     62 def dispatch(self, *args, **kwargs):
     63     """Runs the plotting function by passing the object instance to it."""
---> 64     return self._plot(self._obj, *args, **kwargs)

File ~/checkouts/readthedocs.org/user_builds/sisl/conda/stable/lib/python3.12/site-packages/sisl/viz/_plotables.py:312, in register_data_source.<locals>._plot(obj, __params_info, __signature, *args, **kwargs)
    309     if k not in data_kwargs:
    310         data_kwargs[k] = v
--> 312 data = data_source_cls.new(obj, *args, **data_kwargs)
    314 plot_kwargs = bound.arguments.pop(params_info["plot_var_kwarg"], {})
    316 return plot_cls(**{setting_key: data, **bound.arguments, **plot_kwargs})

File ~/checkouts/readthedocs.org/user_builds/sisl/conda/stable/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/stable/lib/python3.12/site-packages/sisl/viz/data/bands.py:321, in BandsData.from_siesta_bands(cls, bands_file)
    316 @new.register
    317 @classmethod
    318 def from_siesta_bands(cls, bands_file: bandsSileSiesta):
    319     """Gets the bands data from a SIESTA .bands file"""
--> 321     bands_data = bands_file.read_data(as_dataarray=True)
    322     bands_data.k.attrs["axis"] = {
    323         "tickvals": bands_data.attrs.pop("ticks"),
    324         "ticktext": bands_data.attrs.pop("ticklabels"),
    325     }
    327     return cls.new(bands_data)

File ~/checkouts/readthedocs.org/user_builds/sisl/conda/stable/lib/python3.12/site-packages/sisl/io/sile.py:689, in sile_fh_open.<locals>._wrapper.<locals>.pre_open(self, *args, **kwargs)
    687 if hasattr(self, "fh"):
    688     return func(self, *args, **kwargs)
--> 689 with self:
    690     reset(self)
    691     return func(self, *args, **kwargs)

File ~/checkouts/readthedocs.org/user_builds/sisl/conda/stable/lib/python3.12/site-packages/sisl/io/sile.py:1018, in Sile.__enter__(self)
   1016 def __enter__(self):
   1017     """Opens the output file and returns it self"""
-> 1018     self._open()
   1019     return self

File ~/checkouts/readthedocs.org/user_builds/sisl/conda/stable/lib/python3.12/site-packages/sisl/io/sile.py:1009, in Sile._open(self)
   1007             self.fh = gzip.open(str(self.file), mode=self._mode)
   1008     else:
-> 1009         self.fh = self.file.open(self._mode)
   1011 # the file should restart the file-read (as per instructed)
   1012 self._line = 0

File ~/checkouts/readthedocs.org/user_builds/sisl/conda/stable/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/stable/lib/python3.12/site-packages/sisl/viz/_plotables.py:56, in ObjectPlotHandler.__call__(self, *args, **kwargs)
     52 if self._default is None:
     53     raise TypeError(
     54         f"No default plotting function has been defined for {self._obj.__class__.__name__}."
     55     )
---> 56 return getattr(self, self._default)(*args, **kwargs)

File ~/checkouts/readthedocs.org/user_builds/sisl/conda/stable/lib/python3.12/site-packages/sisl/_dispatcher.py:65, in AbstractDispatch.__call__(self, *args, **kwargs)
     63 def __call__(self, *args, **kwargs):
     64     _log.debug(f"call {self.__class__.__name__}{args}", extra={"obj": self})
---> 65     return self.dispatch(*args, **kwargs)

File ~/checkouts/readthedocs.org/user_builds/sisl/conda/stable/lib/python3.12/site-packages/sisl/viz/_plotables.py:64, in PlotDispatch.dispatch(self, *args, **kwargs)
     62 def dispatch(self, *args, **kwargs):
     63     """Runs the plotting function by passing the object instance to it."""
---> 64     return self._plot(self._obj, *args, **kwargs)

File ~/checkouts/readthedocs.org/user_builds/sisl/conda/stable/lib/python3.12/site-packages/sisl/viz/_plotables.py:423, in register_sile_method.<locals>._plot(obj, *args, **kwargs)
    418 except:
    419     raise TypeError(
    420         f"Error while parsing arguments to create the call {method}"
    421     )
--> 423 data = func(obj, *args, **data_kwargs)
    425 plot_kwargs = bound.arguments.pop(params_info["plot_var_kwarg"], {})
    427 return plot_cls(**{setting_key: data, **bound.arguments, **plot_kwargs})

File ~/checkouts/readthedocs.org/user_builds/sisl/conda/stable/lib/python3.12/site-packages/sisl/io/siesta/binaries.py:1889, in _gridSileSiesta.read_grid(self, index, dtype, *args, **kwargs)
   1887 index = kwargs.get("spin", index)
   1888 # Read the sizes and cell
-> 1889 nspin, mesh = self.read_grid_size()
   1890 lattice = self.read_lattice()
   1891 grid = _siesta.read_grid(self.file, nspin, mesh[0], mesh[1], mesh[2])

File ~/checkouts/readthedocs.org/user_builds/sisl/conda/stable/lib/python3.12/site-packages/sisl/io/siesta/binaries.py:1869, in _gridSileSiesta.read_grid_size(self)
   1867 # Read the sizes
   1868 nspin, mesh = _siesta.read_grid_sizes(self.file)
-> 1869 self._fortran_check("read_grid_size", "could not read grid sizes.")
   1870 return nspin, mesh

File ~/checkouts/readthedocs.org/user_builds/sisl/conda/stable/lib/python3.12/site-packages/sisl/io/siesta/sile.py:49, in SileBinSiesta._fortran_check(self, method, message, ret_msg)
     47     msg = f"{self!s}.{method} {message} (ierr={ierr})"
     48     if not ret_msg:
---> 49         raise SileError(msg)
     50 if ret_msg:
     51     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/stable/lib/python3.12/site-packages/sisl/viz/_plotables.py:56, in ObjectPlotHandler.__call__(self, *args, **kwargs)
     52 if self._default is None:
     53     raise TypeError(
     54         f"No default plotting function has been defined for {self._obj.__class__.__name__}."
     55     )
---> 56 return getattr(self, self._default)(*args, **kwargs)

File ~/checkouts/readthedocs.org/user_builds/sisl/conda/stable/lib/python3.12/site-packages/sisl/_dispatcher.py:65, in AbstractDispatch.__call__(self, *args, **kwargs)
     63 def __call__(self, *args, **kwargs):
     64     _log.debug(f"call {self.__class__.__name__}{args}", extra={"obj": self})
---> 65     return self.dispatch(*args, **kwargs)

File ~/checkouts/readthedocs.org/user_builds/sisl/conda/stable/lib/python3.12/site-packages/sisl/viz/_plotables.py:64, in PlotDispatch.dispatch(self, *args, **kwargs)
     62 def dispatch(self, *args, **kwargs):
     63     """Runs the plotting function by passing the object instance to it."""
---> 64     return self._plot(self._obj, *args, **kwargs)

File ~/checkouts/readthedocs.org/user_builds/sisl/conda/stable/lib/python3.12/site-packages/sisl/viz/_plotables.py:312, in register_data_source.<locals>._plot(obj, __params_info, __signature, *args, **kwargs)
    309     if k not in data_kwargs:
    310         data_kwargs[k] = v
--> 312 data = data_source_cls.new(obj, *args, **data_kwargs)
    314 plot_kwargs = bound.arguments.pop(params_info["plot_var_kwarg"], {})
    316 return plot_cls(**{setting_key: data, **bound.arguments, **plot_kwargs})

File ~/checkouts/readthedocs.org/user_builds/sisl/conda/stable/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/stable/lib/python3.12/site-packages/sisl/viz/data/pdos.py:274, in PDOSData.from_siesta_pdos(cls, pdos_file)
    272 """Gets the PDOS from a SIESTA PDOS file"""
    273 # Get the info from the .PDOS file
--> 274 geometry, E, PDOS = pdos_file.read_data()
    276 return cls.new(PDOS, geometry, E)

File ~/checkouts/readthedocs.org/user_builds/sisl/conda/stable/lib/python3.12/site-packages/sisl/io/sile.py:672, in sile_fh_open.<locals>._wrapper.<locals>.pre_open(self, *args, **kwargs)
    669     def _reset(self):
    670         pass
--> 672 with self:
    673     # REMARK this requires the __enter__ to seek(0)
    674     # for the file, and currently it does
    675     _reset(self)
    676     return func(self, *args, **kwargs)

File ~/checkouts/readthedocs.org/user_builds/sisl/conda/stable/lib/python3.12/site-packages/sisl/io/sile.py:1018, in Sile.__enter__(self)
   1016 def __enter__(self):
   1017     """Opens the output file and returns it self"""
-> 1018     self._open()
   1019     return self

File ~/checkouts/readthedocs.org/user_builds/sisl/conda/stable/lib/python3.12/site-packages/sisl/io/sile.py:1009, in Sile._open(self)
   1007             self.fh = gzip.open(str(self.file), mode=self._mode)
   1008     else:
-> 1009         self.fh = self.file.open(self._mode)
   1011 # the file should restart the file-read (as per instructed)
   1012 self._line = 0

File ~/checkouts/readthedocs.org/user_builds/sisl/conda/stable/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/stable/lib/python3.12/site-packages/sisl/_dispatcher.py:65, in AbstractDispatch.__call__(self, *args, **kwargs)
     63 def __call__(self, *args, **kwargs):
     64     _log.debug(f"call {self.__class__.__name__}{args}", extra={"obj": self})
---> 65     return self.dispatch(*args, **kwargs)

File ~/checkouts/readthedocs.org/user_builds/sisl/conda/stable/lib/python3.12/site-packages/sisl/viz/_plotables.py:64, in PlotDispatch.dispatch(self, *args, **kwargs)
     62 def dispatch(self, *args, **kwargs):
     63     """Runs the plotting function by passing the object instance to it."""
---> 64     return self._plot(self._obj, *args, **kwargs)

File ~/checkouts/readthedocs.org/user_builds/sisl/conda/stable/lib/python3.12/site-packages/sisl/viz/_plotables.py:423, in register_sile_method.<locals>._plot(obj, *args, **kwargs)
    418 except:
    419     raise TypeError(
    420         f"Error while parsing arguments to create the call {method}"
    421     )
--> 423 data = func(obj, *args, **data_kwargs)
    425 plot_kwargs = bound.arguments.pop(params_info["plot_var_kwarg"], {})
    427 return plot_cls(**{setting_key: data, **bound.arguments, **plot_kwargs})

File ~/checkouts/readthedocs.org/user_builds/sisl/conda/stable/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/stable/lib/python3.12/site-packages/sisl/io/sile.py:672, in sile_fh_open.<locals>._wrapper.<locals>.pre_open(self, *args, **kwargs)
    669     def _reset(self):
    670         pass
--> 672 with self:
    673     # REMARK this requires the __enter__ to seek(0)
    674     # for the file, and currently it does
    675     _reset(self)
    676     return func(self, *args, **kwargs)

File ~/checkouts/readthedocs.org/user_builds/sisl/conda/stable/lib/python3.12/site-packages/sisl/io/sile.py:1018, in Sile.__enter__(self)
   1016 def __enter__(self):
   1017     """Opens the output file and returns it self"""
-> 1018     self._open()
   1019     return self

File ~/checkouts/readthedocs.org/user_builds/sisl/conda/stable/lib/python3.12/site-packages/sisl/io/sile.py:1009, in Sile._open(self)
   1007             self.fh = gzip.open(str(self.file), mode=self._mode)
   1008     else:
-> 1009         self.fh = self.file.open(self._mode)
   1011 # the file should restart the file-read (as per instructed)
   1012 self._line = 0

File ~/checkouts/readthedocs.org/user_builds/sisl/conda/stable/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/stable/lib/python3.12/site-packages/sisl/viz/_plotables.py:56, in ObjectPlotHandler.__call__(self, *args, **kwargs)
     52 if self._default is None:
     53     raise TypeError(
     54         f"No default plotting function has been defined for {self._obj.__class__.__name__}."
     55     )
---> 56 return getattr(self, self._default)(*args, **kwargs)

File ~/checkouts/readthedocs.org/user_builds/sisl/conda/stable/lib/python3.12/site-packages/sisl/_dispatcher.py:65, in AbstractDispatch.__call__(self, *args, **kwargs)
     63 def __call__(self, *args, **kwargs):
     64     _log.debug(f"call {self.__class__.__name__}{args}", extra={"obj": self})
---> 65     return self.dispatch(*args, **kwargs)

File ~/checkouts/readthedocs.org/user_builds/sisl/conda/stable/lib/python3.12/site-packages/sisl/viz/_plotables.py:64, in PlotDispatch.dispatch(self, *args, **kwargs)
     62 def dispatch(self, *args, **kwargs):
     63     """Runs the plotting function by passing the object instance to it."""
---> 64     return self._plot(self._obj, *args, **kwargs)

File ~/checkouts/readthedocs.org/user_builds/sisl/conda/stable/lib/python3.12/site-packages/sisl/viz/_plotables.py:312, in register_data_source.<locals>._plot(obj, __params_info, __signature, *args, **kwargs)
    309     if k not in data_kwargs:
    310         data_kwargs[k] = v
--> 312 data = data_source_cls.new(obj, *args, **data_kwargs)
    314 plot_kwargs = bound.arguments.pop(params_info["plot_var_kwarg"], {})
    316 return plot_cls(**{setting_key: data, **bound.arguments, **plot_kwargs})

File ~/checkouts/readthedocs.org/user_builds/sisl/conda/stable/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/stable/lib/python3.12/site-packages/sisl/viz/data/pdos.py:274, in PDOSData.from_siesta_pdos(cls, pdos_file)
    272 """Gets the PDOS from a SIESTA PDOS file"""
    273 # Get the info from the .PDOS file
--> 274 geometry, E, PDOS = pdos_file.read_data()
    276 return cls.new(PDOS, geometry, E)

File ~/checkouts/readthedocs.org/user_builds/sisl/conda/stable/lib/python3.12/site-packages/sisl/io/sile.py:672, in sile_fh_open.<locals>._wrapper.<locals>.pre_open(self, *args, **kwargs)
    669     def _reset(self):
    670         pass
--> 672 with self:
    673     # REMARK this requires the __enter__ to seek(0)
    674     # for the file, and currently it does
    675     _reset(self)
    676     return func(self, *args, **kwargs)

File ~/checkouts/readthedocs.org/user_builds/sisl/conda/stable/lib/python3.12/site-packages/sisl/io/sile.py:1018, in Sile.__enter__(self)
   1016 def __enter__(self):
   1017     """Opens the output file and returns it self"""
-> 1018     self._open()
   1019     return self

File ~/checkouts/readthedocs.org/user_builds/sisl/conda/stable/lib/python3.12/site-packages/sisl/io/sile.py:1009, in Sile._open(self)
   1007             self.fh = gzip.open(str(self.file), mode=self._mode)
   1008     else:
-> 1009         self.fh = self.file.open(self._mode)
   1011 # the file should restart the file-read (as per instructed)
   1012 self._line = 0

File ~/checkouts/readthedocs.org/user_builds/sisl/conda/stable/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/stable/lib/python3.12/site-packages/sisl/viz/_plotables.py:56, in ObjectPlotHandler.__call__(self, *args, **kwargs)
     52 if self._default is None:
     53     raise TypeError(
     54         f"No default plotting function has been defined for {self._obj.__class__.__name__}."
     55     )
---> 56 return getattr(self, self._default)(*args, **kwargs)

File ~/checkouts/readthedocs.org/user_builds/sisl/conda/stable/lib/python3.12/site-packages/sisl/_dispatcher.py:65, in AbstractDispatch.__call__(self, *args, **kwargs)
     63 def __call__(self, *args, **kwargs):
     64     _log.debug(f"call {self.__class__.__name__}{args}", extra={"obj": self})
---> 65     return self.dispatch(*args, **kwargs)

File ~/checkouts/readthedocs.org/user_builds/sisl/conda/stable/lib/python3.12/site-packages/sisl/viz/_plotables.py:64, in PlotDispatch.dispatch(self, *args, **kwargs)
     62 def dispatch(self, *args, **kwargs):
     63     """Runs the plotting function by passing the object instance to it."""
---> 64     return self._plot(self._obj, *args, **kwargs)

File ~/checkouts/readthedocs.org/user_builds/sisl/conda/stable/lib/python3.12/site-packages/sisl/viz/_plotables.py:423, in register_sile_method.<locals>._plot(obj, *args, **kwargs)
    418 except:
    419     raise TypeError(
    420         f"Error while parsing arguments to create the call {method}"
    421     )
--> 423 data = func(obj, *args, **data_kwargs)
    425 plot_kwargs = bound.arguments.pop(params_info["plot_var_kwarg"], {})
    427 return plot_cls(**{setting_key: data, **bound.arguments, **plot_kwargs})

File ~/checkouts/readthedocs.org/user_builds/sisl/conda/stable/lib/python3.12/site-packages/sisl/io/siesta/binaries.py:1889, in _gridSileSiesta.read_grid(self, index, dtype, *args, **kwargs)
   1887 index = kwargs.get("spin", index)
   1888 # Read the sizes and cell
-> 1889 nspin, mesh = self.read_grid_size()
   1890 lattice = self.read_lattice()
   1891 grid = _siesta.read_grid(self.file, nspin, mesh[0], mesh[1], mesh[2])

File ~/checkouts/readthedocs.org/user_builds/sisl/conda/stable/lib/python3.12/site-packages/sisl/io/siesta/binaries.py:1869, in _gridSileSiesta.read_grid_size(self)
   1867 # Read the sizes
   1868 nspin, mesh = _siesta.read_grid_sizes(self.file)
-> 1869 self._fortran_check("read_grid_size", "could not read grid sizes.")
   1870 return nspin, mesh

File ~/checkouts/readthedocs.org/user_builds/sisl/conda/stable/lib/python3.12/site-packages/sisl/io/siesta/sile.py:49, in SileBinSiesta._fortran_check(self, method, message, ret_msg)
     47     msg = f"{self!s}.{method} {message} (ierr={ierr})"
     48     if not ret_msg:
---> 49         raise SileError(msg)
     50 if ret_msg:
     51     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)
[ ]: