zerothi / sisl

Electronic structure Python package for post analysis and large scale tight-binding DFT/NEGF calculations
https://zerothi.github.io/sisl
Mozilla Public License 2.0
173 stars 57 forks source link

Legend grouping in bands plots #784

Closed pfebrer closed 1 month ago

pfebrer commented 1 month ago

This PR solves two problems:

import sisl

# First, we create the geometry
BN = sisl.geom.graphene(atoms=["B", "N"])

# Create a hamiltonian with different on-site terms
H = sisl.Hamiltonian(BN)

H[0, 0] = 2
H[1, 1] = -2

H[0, 1] = -2.7
H[1, 0] = -2.7

H[0, 1, (-1, 0)] = -2.7
H[0, 1, (0, -1)] = -2.7
H[1, 0, (1, 0)] = -2.7
H[1, 0, (0, 1)] = -2.7

band = sisl.BandStructure(
    H,
    [[0.0, 0.0], [2.0 / 3, 1.0 / 3], [1.0 / 2, 1.0 / 2], [1.0, 1.0]],
    301,
    [r"Gamma", "K", "M", r"Gamma"],
)

fatbands = band.plot.fatbands(backend="matplotlib")
fatbands.split_groups(name="$species")
fatbands.axes.legend()

Screenshot from 2024-06-05 01-18-31

Reverting legend grouping for bands:

fatbands.update_inputs(bands_group_legend=False).legend()

Screenshot from 2024-06-05 01-23-49

codecov[bot] commented 1 month ago

Codecov Report

Attention: Patch coverage is 69.04762% with 13 lines in your changes missing coverage. Please review.

Project coverage is 87.35%. Comparing base (1d3f4da) to head (d3a6b90).

Files Patch % Lines
src/sisl/viz/processors/bands.py 41.66% 7 Missing :warning:
src/sisl/viz/plots/bands.py 85.00% 3 Missing :warning:
src/sisl/viz/figure/matplotlib.py 50.00% 2 Missing :warning:
src/sisl/viz/plotters/xarray.py 83.33% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #784 +/- ## ======================================= Coverage 87.34% 87.35% ======================================= Files 396 396 Lines 50750 50757 +7 ======================================= + Hits 44330 44340 +10 + Misses 6420 6417 -3 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.