sisl.viz.AtomicMatrixPlot

class sisl.viz.AtomicMatrixPlot(matrix: np.ndarray | SparseCSR | SparseAtom | SparseOrbital | spmatrix, dim: int = 0, isc: int | None = None, fill_value: float | None = None, geometry: Geometry | None = None, atom_lines: bool | dict = False, orbital_lines: bool | dict = False, sc_lines: bool | dict = False, color_pixels: bool = True, colorscale: Colorscale | None = 'RdBu', crange: tuple[float, float] | None = None, cmid: float | None = None, text: str | None = None, textfont: dict | None = {}, set_labels: bool = False, constrain_axes: bool = True, arrows: list[dict] = [], backend: str = 'plotly')[source]

Bases: Plot

Plots a (possibly sparse) matrix where rows and columns are either orbitals or atoms.

Parameters:
  • matrix – the matrix, either as a numpy array or as a sisl sparse matrix.

  • dim – If the matrix has a third dimension (e.g. spin), which index to plot in that third dimension.

  • isc – If the matrix contains data for an auxiliary supercell, the index of the cell to plot. If None, the whole matrix is plotted.

  • fill_value – If the matrix is sparse, the value to use for the missing entries.

  • geometry – Only needed if the matrix does not contain a geometry (e.g. it is a numpy array) and separator lines or labels are requested.

  • atom_lines – If a boolean, whether to draw lines separating atom blocks, using default styles. If a dict, draws the lines with the specified plotly line styles.

  • orbital_lines – If a boolean, whether to draw lines separating blocks of orbital sets, using default styles. If a dict, draws the lines with the specified plotly line styles.

  • sc_lines – If a boolean, whether to draw lines separating the supercells, using default styles. If a dict, draws the lines with the specified plotly line styles.

  • color_pixels – Whether to color the pixels of the matrix according to the colorscale.

  • colorscale – The colorscale to use to color the pixels.

  • crange – The minimum and maximum values of the colorscale.

  • cmid – The midpoint of the colorscale. If crange is provided, this is ignored.

    If None and crange is also None, the midpoint is set to 0 if the data contains both positive and negative values.

  • text – If provided, show text of pixel value with the specified format. E.g. text=”.3f” shows the value with three decimal places.

  • textfont – The font to use for the text. This is a dictionary that may contain the keys “family”, “size”, “color”.

  • set_labels – Whether to set the axes labels to the atom/orbital that each row and column corresponds to. For orbitals the labels will be of the form “Atom: (l, m)”, where Atom is the index of the atom and l and m are the quantum numbers of the orbital.

  • constrain_axes – Whether to set the ranges of the axes to exactly fit the matrix.

  • backend – The backend to use for plotting.

Methods

evaluate_input_node(node)

final_node_key(*args)

Returns the key of the final (output) node of the workflow.

find_node_key(node, *args)

Returns the identifier key of a node in this workflow

from_func([func, context, module])

Builds a node from a function.

from_node_tree(output_node[, workflow_name])

Creates a workflow class from a node.

function(matrix[, dim, isc, fill_value, ...])

Plots a (possibly sparse) matrix where rows and columns are either orbitals or atoms.

get()

Returns the up to date output of the workflow.

get_diagram_label()

Returns the label to be used in diagrams when displaying this node.

get_input(key)

get_tree()

is_output_outdated(evaluated_inputs)

Checks if the node needs to be ran

map_inputs(inputs, func[, only_nodes, exclude])

Maps all inputs of the node applying a given function.

merge(*others, **kwargs)

plot_class_key()

recursive_update_inputs([cls])

Updates the inputs of the node recursively.

setup(*args, **kwargs)

Sets up the node based on its initial inputs.

update_inputs(**inputs)

Updates the inputs of the workflow.

update_settings(*args, **kwargs)

Attributes

DELETE_KWARG

context

default_inputs

dryrun_nodes

get_syntax

inputs

last_log

Last time the logs of this node were updated

network

nodes

logs

__call__(*args, **kwargs)

Call self as a function.

static evaluate_input_node(node: Node)
classmethod final_node_key(*args) str

Returns the key of the final (output) node of the workflow.

classmethod find_node_key(node, *args) str

Returns the identifier key of a node in this workflow

classmethod from_func(func: Callable | None = None, context: dict | None = None, module: str | None = None)

Builds a node from a function.

Parameters:
  • func (function, optional) – The function to be converted to a node.

    If not provided, the return of this method is just a lambda function that expects the function. This is useful if you want to use this method as a decorator while also providing extra arguments (like the context argument).

  • context (dict, optional) – The context to be used as the default for the node class that will be created.

classmethod from_node_tree(output_node: Node, workflow_name: str | None = None)

Creates a workflow class from a node.

It does so by recursively traversing the tree in the inputs direction until it finds the leaves. All the nodes found are included in the workflow. For each node, inputs that are not nodes are connected to the inputs of the workflow.

Parameters:
  • output_node (Node) – The final node, that should be connected to the output of the workflow.

  • workflow_name (str, optional) – The name of the new workflow class. If None, the name of the output node will be used.

Returns:

Workflow – The newly created workflow class.

static function(matrix: ndarray | SparseCSR | SparseAtom | SparseOrbital | spmatrix, dim: int = 0, isc: int | None = None, fill_value: float | None = None, geometry: Geometry | None = None, atom_lines: bool | dict = False, orbital_lines: bool | dict = False, sc_lines: bool | dict = False, color_pixels: bool = True, colorscale: str | Sequence[Color] | Sequence[tuple[float, Color]] | None = 'RdBu', crange: tuple[float, float] | None = None, cmid: float | None = None, text: str | None = None, textfont: dict | None = {}, set_labels: bool = False, constrain_axes: bool = True, arrows: list[dict] = [], backend: str = 'plotly') Figure

Plots a (possibly sparse) matrix where rows and columns are either orbitals or atoms.

Parameters:
  • matrix – the matrix, either as a numpy array or as a sisl sparse matrix.

  • dim – If the matrix has a third dimension (e.g. spin), which index to plot in that third dimension.

  • isc – If the matrix contains data for an auxiliary supercell, the index of the cell to plot. If None, the whole matrix is plotted.

  • fill_value – If the matrix is sparse, the value to use for the missing entries.

  • geometry – Only needed if the matrix does not contain a geometry (e.g. it is a numpy array) and separator lines or labels are requested.

  • atom_lines – If a boolean, whether to draw lines separating atom blocks, using default styles. If a dict, draws the lines with the specified plotly line styles.

  • orbital_lines – If a boolean, whether to draw lines separating blocks of orbital sets, using default styles. If a dict, draws the lines with the specified plotly line styles.

  • sc_lines – If a boolean, whether to draw lines separating the supercells, using default styles. If a dict, draws the lines with the specified plotly line styles.

  • color_pixels – Whether to color the pixels of the matrix according to the colorscale.

  • colorscale – The colorscale to use to color the pixels.

  • crange – The minimum and maximum values of the colorscale.

  • cmid – The midpoint of the colorscale. If crange is provided, this is ignored.

    If None and crange is also None, the midpoint is set to 0 if the data contains both positive and negative values.

  • text – If provided, show text of pixel value with the specified format. E.g. text=”.3f” shows the value with three decimal places.

  • textfont – The font to use for the text. This is a dictionary that may contain the keys “family”, “size”, “color”.

  • set_labels – Whether to set the axes labels to the atom/orbital that each row and column corresponds to. For orbitals the labels will be of the form “Atom: (l, m)”, where Atom is the index of the atom and l and m are the quantum numbers of the orbital.

  • constrain_axes – Whether to set the ranges of the axes to exactly fit the matrix.

  • backend – The backend to use for plotting.

get()

Returns the up to date output of the workflow.

It will recompute it if necessary.

get_diagram_label()

Returns the label to be used in diagrams when displaying this node.

get_input(key: str)
get_tree()
is_output_outdated(evaluated_inputs: Dict[str, Any])

Checks if the node needs to be ran

map_inputs(inputs: Dict[str, Any], func: Callable, only_nodes: bool = False, exclude: Sequence[str] = ()) Dict[str, Any]

Maps all inputs of the node applying a given function.

It considers the args and kwargs keys.

Parameters:
  • inputs (Dict[str, Any]) – The inputs of the node.

  • func (Callable) – The function to apply to each value.

  • only_nodes (bool, optional) – Whether to apply the function only to nodes, by default False.

  • exclude (Sequence[str], optional) – The keys to exclude from the mapping. This means that these keys are returned as they are.

merge(*others, **kwargs)
classmethod plot_class_key() str
recursive_update_inputs(cls: Type | Tuple[Type, ...] | None = None, **inputs)

Updates the inputs of the node recursively.

This method updates the inputs of get node and all its children.

Parameters:
  • cls (Optional[Union[Type, Tuple[Type, ]]], optional) – Only update nodes of this class. If None, update all nodes.

  • inputs (Dict[str, Any]) – The inputs to update.

setup(*args, **kwargs)

Sets up the node based on its initial inputs.

update_inputs(**inputs)

Updates the inputs of the workflow.

update_settings(*args, **kwargs)
DELETE_KWARG = <object object>
context: NodeContext = NodeContext({}, {}, {}, {}, {'lazy': True, 'lazy_init': None, 'log_level': 'INFO', 'raise_custom_errors': False, 'on_init': None, 'batch_iter': 'zip'})
property default_inputs
dryrun_nodes: WorkflowNodes = <nodify.workflow.WorkflowNodes object>
get_syntax: Callable[[Any], str] | None = None
property inputs
property last_log: float

Last time the logs of this node were updated

logs: str
network = <nodify.workflow.Network object>
nodes: WorkflowNodes