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
182 stars 58 forks source link

Allow custom color scales across sisl.viz #786

Closed pfebrer closed 3 months ago

pfebrer commented 3 months ago

Closes #785

Now one can pass a custom colorscale to any colorscale argument in the plots of sisl.viz.

E.g.:

import sisl

plot = sisl.geom.graphene().tile(2, 0).plot(
    atoms_style={"color": [0, 0.25, 0.75, 1]}, 
    atoms_colorscale=["rgb(255, 0, 0)", "rgb(0, 0, 255)"], 
)

plot

Screenshot from 2024-06-11 19-24-13

plot.update_inputs(axes="xy", atoms_scale=20, backend="matplotlib")

Screenshot from 2024-06-11 19-22-28

All plotly named colorscales (e.g. "balance") also work now for the 3D geometry plot.

Thanks @saru1799!

codecov[bot] commented 3 months ago

Codecov Report

Attention: Patch coverage is 51.72414% with 14 lines in your changes missing coverage. Please review.

Project coverage is 87.28%. Comparing base (255efb1) to head (e83dba0). Report is 1 commits behind head on main.

Files Patch % Lines
src/sisl/viz/figure/matplotlib.py 38.46% 8 Missing :warning:
src/sisl/viz/plotutils.py 33.33% 4 Missing :warning:
src/sisl/viz/figure/plotly.py 50.00% 2 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #786 +/- ## ========================================== - Coverage 87.28% 87.28% -0.01% ========================================== Files 397 397 Lines 50919 50925 +6 ========================================== + Hits 44446 44448 +2 - Misses 6473 6477 +4 ```

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