Skip to content

Remove matplotlib-based periodic table plotting functions #270

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 6 commits into from
Feb 24, 2025

Conversation

janosh
Copy link
Owner

@janosh janosh commented Feb 24, 2025

  • Remove ptable_matplotlib.py, _process_data.py, and _projector.py
  • Update __init__.py to remove matplotlib-based periodic table imports
  • Update readme to focus on plotly-based periodic table visualization
  • Add ptable_matplotlib.py removal note in readme recommending use of equivalent plotly functions instead

…atplotlib.py

- Remove `ptable_matplotlib.py`, `_process_data.py`, and `_projector.py`
- Update `__init__.py` to remove matplotlib-based periodic table imports
- Update README to focus on plotly-based periodic table visualization
- Add `ptable_matplotlib.py` removal note in readme recommending use of equivalent plotly functions instead
@janosh janosh added matplotlib Concerning matplotlib-powered functions housekeeping Keep the code base tidy. breaking Breaking changes api Application programming interface labels Feb 24, 2025
Copy link

codecov bot commented Feb 24, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.17%. Comparing base (502c573) to head (040c123).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #270      +/-   ##
==========================================
+ Coverage   86.62%   87.17%   +0.54%     
==========================================
  Files          47       44       -3     
  Lines        5211     4591     -620     
  Branches      983      863     -120     
==========================================
- Hits         4514     4002     -512     
+ Misses        430      370      -60     
+ Partials      267      219      -48     

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

@janosh janosh requested a review from DanielYang59 February 24, 2025 12:34
@janosh
Copy link
Owner Author

janosh commented Feb 24, 2025

@DanielYang59 i know you put a lot of work into refactoring the matplotlib ptable_* functions last year but given we now have feature parity with the plotly variants which offer interactivity and have better test coverage than their matplotlib equivalents, i think it makes sense to remove the matplotlib versions altogether.

coverage of the ptable folder

Screenshot 2025-02-24 at 6 40 18 AM

following the Zen of Python, i think it's best if there's just 1 way to plot periodic tables

There should be one-- and preferably only one --obvious way to do it.

i find plotly easier to maintain and add features to, and it's also less confusing to users if pymatviz exposes an overall smaller set of plot functions without any redundancy

…ady have plotly equivalents to assets/scripts/ptable_plotly

- Add new visualization examples in ptable_heatmap_plotly.py comparing element counts across datasets
- ptable_hists_plotly.py add second example with horizontal colorbar and annotations
- ptable_scatter_plotly.py add parabola data and more color/annotation strategies
- ptable_plotly.py remove linebreak insertion in horizontal colorbar titles
@DanielYang59
Copy link
Collaborator

Hi @janosh thanks for asking me!

No need to worry about the sunk cost of the mpl ptable plotters, as long as plotly alternatives could completely replace their functionality even in terms of non-interactive plots (also perhaps they could be used in the future to simplify plotly plotters as it seems to me plot ptable plotters seem to have quite some code repetition in terms of laying down the structure of ptable).

I would certainly be on deck to migrate to plotly, but I'm a bit concerned about the breakage per se (as periodic table plotters in my option is a pretty "core" functionality of pmv), though I understand you usually want changes to happen fast ;)

@janosh
Copy link
Owner Author

janosh commented Feb 24, 2025

ploty ptable plotters seem to have quite some code repetition in terms of laying down the structure of ptable).

that's a fair point. certainly worth trying to DRY the code at some point though from past experience, there's a significant risk of making the different plots harder to maintain from coupling them too closely

though I understand you usually want changes to happen fast ;)

you know me by now. 😅 i was going to deprecate first but then realized i wouldn't be able to increase the target test coverage in Codecov if the module is still around. maybe there's a way to exclude module from mean coverage calculations but didn't feel like researching that or adding new tests for soon-to-be-removed functionality

@DanielYang59
Copy link
Collaborator

i wouldn't be able to increase the target test coverage in Codecov if the module is still around. maybe there's a way to exclude module from mean coverage calculations but didn't feel like researching that or adding new tests for soon-to-be-removed functionality

I wouldn't worry too much about the number shown by codecov maybe (especially for our plotter code base)? I just had a quick glance at the coverage and it seems most misses are from type checking imports (no idea why), or warnings for deprecated args of ptable_heatmap. So shouldn't be concerning IMO.

@janosh
Copy link
Owner Author

janosh commented Feb 24, 2025

I just had a quick glance at the coverage and it seems most misses are from type checking imports (no idea why)

looks like i need to check how to configure Codecov after all to exclude those lines from coverage calculating. pymatgen does it in pyproject.toml. still, since the same settings apply to the plotly modules, relative differences in coverage are still meaningful, no? even if the actual coverage on coverable lines is slightly higher in both cases

…functions and remove PDF outputs

- Migrate dataset exploration scripts to use Plotly-based visualizations
- in hindsight, no need to keep PDF outputs under version control
- refactor imports to use `import pymatviz as pmv` instead of individual function imports
- update Key enum to use `n_wyckoff_pos` instead of `n_wyckoff`
@janosh janosh merged commit 7ea6f93 into main Feb 24, 2025
8 of 9 checks passed
@janosh janosh deleted the remove-ptable-matplotlib branch February 24, 2025 17:05
@janosh janosh mentioned this pull request Mar 1, 2025
janosh added a commit that referenced this pull request Mar 28, 2025
* remove matplotlib-based periodic table plotting functions in ptable_matplotlib.py

- Remove `ptable_matplotlib.py`, `_process_data.py`, and `_projector.py`
- Update `__init__.py` to remove matplotlib-based periodic table imports
- Update README to focus on plotly-based periodic table visualization
- Add `ptable_matplotlib.py` removal note in readme recommending use of equivalent plotly functions instead

* assets/scripts/ptable_matplotlib migrate any examples that don't already have plotly equivalents to assets/scripts/ptable_plotly

- Add new visualization examples in ptable_heatmap_plotly.py comparing element counts across datasets
- ptable_hists_plotly.py add second example with horizontal colorbar and annotations
- ptable_scatter_plotly.py add parabola data and more color/annotation strategies
- ptable_plotly.py remove linebreak insertion in horizontal colorbar titles

* rm -r assets/scripts/ptable_matplotlib

* remove matplotlib ptable SVG assets

* update dataset exploration examples to use Plotly variants of ptable functions and remove PDF outputs

- Migrate dataset exploration scripts to use Plotly-based visualizations
- in hindsight, no need to keep PDF outputs under version control
- refactor imports to use `import pymatviz as pmv` instead of individual function imports
- update Key enum to use `n_wyckoff_pos` instead of `n_wyckoff`

* update count_elements() docstring to point at Plotly ptable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api Application programming interface breaking Breaking changes housekeeping Keep the code base tidy. matplotlib Concerning matplotlib-powered functions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants