Download IPython notebook here. Binder badge.

Adding new backends

import sisl
import sisl.viz

# This is a toy band structure to illustrate the concepts treated throughout the notebook
geom = sisl.geom.graphene(orthogonal=True)
H = sisl.Hamiltonian(geom)
H.construct([(0.1, 1.44), (0, -2.7)], )

band_struct = sisl.BandStructure(H, [[0,0,0], [0.5,0,0]], 10, ["Gamma", "X"])

In the sisl.viz framework, the rendering part of the visualization is completely detached from the processing part. Because of that, we have the flexibility to add new ways of generating the final product by registering what we call backends.

We will guide you through how you might customize this part of the framework. There are however, very distinct scenarios where you might find yourself. Each of the following sections explains the details of each situation, which are ordered in increasing complexity.


Even if you want to go to the most complex situation, make sure that you first understand the simpler ones!

Extending an existing backend

This is by far the easiest situation. For example, sisl already provides a backend to plot bands with plotly, but you are not totally happy with the way it’s done.

In this case, you grab the provided backend:

from sisl.viz.backends.plotly import PlotlyBandsBackend

And then create your own class that inherits from it:

class MyOwnBandsBackend(PlotlyBandsBackend):

The only thing left to do now is to let BandsPlot know that there’s a new backend available. This action is called registering a backend.

from sisl.viz import BandsPlot

BandsPlot.backends.register("plotly_myown", MyOwnBandsBackend)
# Pass default=True if you want to make it the default backend

All good, you can already use your new backend!