Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow custom color scales across sisl.viz #786

Merged
merged 1 commit into from
Jun 11, 2024

Conversation

pfebrer
Copy link
Contributor

@pfebrer pfebrer commented Jun 11, 2024

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!

return colorscale
elif isinstance(colorscale, list):

def _sanitize_scale_item(item):

Check notice

Code scanning / CodeQL

Explicit returns mixed with implicit (fall through) returns Note

Mixing implicit and explicit returns may indicate an error as implicit returns always return None.
Copy link

codecov bot commented Jun 11, 2024

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 ⚠️
src/sisl/viz/plotutils.py 33.33% 4 Missing ⚠️
src/sisl/viz/figure/plotly.py 50.00% 2 Missing ⚠️
Additional details and impacted files
@@            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     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@zerothi zerothi merged commit 35f93da into zerothi:main Jun 11, 2024
7 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Custom colormaps for 3D plots
2 participants