Skip to content

structure_(2|3)d_plotly enable gradient-colored bonds #280

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

Merged
merged 2 commits into from
Mar 10, 2025

Conversation

janosh
Copy link
Owner

@janosh janosh commented Mar 10, 2025

  • Add support for gradient bond coloring using interpolating between colors of connected atoms or custom color lists
  • handles various color formats and interpolation
  • add unit tests for various bond coloring strategies

example:

from matminer.datasets import load_dataset

import pymatviz as pmv
from pymatviz.enums import ElemColorScheme, Key, SiteCoords


df_phonons = load_dataset("matbench_phonons")

fig = pmv.structure_3d_plotly(
    df_phonons[Key.structure].iloc[4].make_supercell(2, in_place=False),
    elem_colors=ElemColorScheme.jmol,
    hover_text=SiteCoords.cartesian_fractional,
    show_bonds=True,
)
fig.show()

Screenshot 2025-03-10 at 3 21 31 PM

- Add support for gradient bond coloring using element colors or custom color lists
- handles various color formats and interpolation
- add unit tests for various bond coloring strategies
@janosh janosh added enhancement Improvement to existing features/functionality plotly Concerning plotly-powered functions structure Structure viz related labels Mar 10, 2025
@janosh janosh merged commit 6ba271a into main Mar 10, 2025
49 checks passed
@janosh janosh deleted the structure-plotly-bond-coloring branch March 10, 2025 19:39
Copy link

codecov bot commented Mar 10, 2025

Codecov Report

Attention: Patch coverage is 91.83673% with 4 lines in your changes missing coverage. Please review.

Project coverage is 87.79%. Comparing base (b984d4a) to head (a5c4341).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
pymatviz/structure_viz/helpers.py 93.75% 3 Missing ⚠️
pymatviz/structure_viz/plotly.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #280      +/-   ##
==========================================
+ Coverage   87.76%   87.79%   +0.02%     
==========================================
  Files          44       44              
  Lines        4651     4677      +26     
  Branches      893      899       +6     
==========================================
+ Hits         4082     4106      +24     
  Misses        358      358              
- Partials      211      213       +2     

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

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

janosh added a commit that referenced this pull request Mar 28, 2025
* structure_(2|3)d_plotly enable gradient-colored bonds

- Add support for gradient bond coloring using element colors or custom color lists
- handles various color formats and interpolation
- add unit tests for various bond coloring strategies

* fix tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvement to existing features/functionality plotly Concerning plotly-powered functions structure Structure viz related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant