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

Fixed matplotlib fatbands and enabled opacity #862

Merged
merged 1 commit into from
Nov 7, 2024

Conversation

pfebrer
Copy link
Contributor

@pfebrer pfebrer commented Nov 7, 2024

#790 had not been fully fixed by #799. There were some bugs regarding fatbands_mode="scatter" and fatbands_mode="line" for the matplotlib backend.

Also enabled the possibility to use "opacity" for all variants of fatbands, to avoid some fatbands getting hidden by the overlap with the next ones.

With the example that @rreho provided using "scatter" "and matplotlib", and setting "opacity": 0.2 for the red fatbands:

Screenshot from 2024-11-07 12-04-55

@pfebrer
Copy link
Contributor Author

pfebrer commented Nov 7, 2024

Here with "area_line", where previously the red area would have hidden the blue one in the valence bands. Now it is clear that both contribute:

Screenshot from 2024-11-07 12-09-06

Copy link

codecov bot commented Nov 7, 2024

Codecov Report

Attention: Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.

Project coverage is 86.98%. Comparing base (309d393) to head (cd8b990).
Report is 8 commits behind head on main.

Files with missing lines Patch % Lines
src/sisl/viz/figure/matplotlib.py 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #862      +/-   ##
==========================================
- Coverage   86.98%   86.98%   -0.01%     
==========================================
  Files         403      403              
  Lines       52552    52559       +7     
==========================================
+ Hits        45712    45717       +5     
- Misses       6840     6842       +2     

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

@@ -380,6 +381,8 @@ def draw_multisize_line(
# Set the values used for colormapping
lc.set_linewidth(line.get("width", 1))
lc.set_linestyle(self._plotly_dash_to_matplotlib(line.get("dash", "solid")))
lc.set_color(line.get("color"))
lc.set_alpha(line.get("opacity"))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a bit pedantic here, but matplotlib users are used to using alpha=, could it allow both things?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would become a complete chaos if I try to support all keywords of all backends 😅
I took the decision to stick to plotly terminology in general to make things easier to maintain and document.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, fair...

@@ -380,6 +381,8 @@ def draw_multisize_line(
# Set the values used for colormapping
lc.set_linewidth(line.get("width", 1))
lc.set_linestyle(self._plotly_dash_to_matplotlib(line.get("dash", "solid")))
lc.set_color(line.get("color"))
lc.set_alpha(line.get("opacity"))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, fair...

@zerothi zerothi merged commit 041518c into zerothi:main Nov 7, 2024
16 of 17 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.

2 participants