Skip to content

Add ptable_scatter #122

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 31 commits into from
Feb 9, 2024
Merged

Add ptable_scatter #122

merged 31 commits into from
Feb 9, 2024

Conversation

DanielYang59
Copy link
Collaborator

@DanielYang59 DanielYang59 commented Feb 2, 2024

closes #119

TODOs:

  • add guide for ptable_hists
  • add ptable_scatter
  • add guide for ptable_scatter
  • allow passing Dict[str, np.ndarray] as data
  • add tests for ptable_scatter (test all possible input data types)

@DanielYang59 DanielYang59 marked this pull request as ready for review February 5, 2024 03:54
@DanielYang59
Copy link
Collaborator Author

Please review @janosh . Thanks!

@DanielYang59 DanielYang59 requested a review from janosh February 5, 2024 04:19
Copy link
Owner

@janosh janosh left a comment

Choose a reason for hiding this comment

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

this is looking really nice! i'll take another closer look tomorrow (lot of meetings today). in the meantime, could you add yourself to the authors list in citation.cff?

@janosh janosh added enhancement Improvement to existing features/functionality matplotlib Concerning matplotlib-powered functions ptable Periodic table labels Feb 5, 2024
readme.md Outdated
| ![ptable-hists] | ![ptable-scatters] |

[ptable-hists]: https://raw.githubusercontent.com/janosh/pymatviz/main/assets/ptable-hists.svg
[ptable-scatters]: https://raw.githubusercontent.com/janosh/pymatviz/main/assets/ptable-scatters.svg
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Sorry this is an overlook from my side, forgot to replace "_" with "-". Meanwhile I thought we're putting all assert svgs together at the end of the readme.md?

@DanielYang59
Copy link
Collaborator Author

this is looking really nice! i'll take another closer look tomorrow (lot of meetings today). in the meantime, could you add yourself to the authors list in citation.cff?

No rush at all. Thanks a lot for offering that but let me leave the honour for later (didn't do much in this PR than copied and modified you and @chiang-yuan's ptable_hists)

Copy link
Owner

@janosh janosh left a comment

Choose a reason for hiding this comment

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

thanks a lot @DanielYang59! great contribution! 👍

one thing i noticed that could be improved:

following your example in examples/_generate_assets.py, I tried

data_dict = {
    ele.symbol: [
        xs := np.random.randn(100),
        xs + 0.2 * np.random.randn(100),
        0.2 * np.random.randn(100),
    ]
    for ele in elements
}

fig = ptable_scatters(
    data_dict, colormap="coolwarm", cbar_title="Periodic Table Scatter Plots"
)

and got

scatter2

would prefer the subplots to always be square so tried adding ax.set_aspect("equal") but then i got very small tiles:

scatter

do you know of a solution?

@@ -318,7 +318,7 @@ def test_ptable_heatmap_plotly_cscale_range(
fig = ptable_heatmap_plotly(df_ptable.density, cscale_range=cscale_range)
trace = fig.data[0]
assert "colorbar" in trace
# check for correct colorbar range
# check for correct color bar range
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think we agreed on using colorbar instead of color bar here...Maybe your spelling checking plugin not updated? @janosh

Copy link
Owner

Choose a reason for hiding this comment

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

yes, the spell checker fixes it. i don't think it makes sense to override the spell checker here since it is actually correct that this is not a word

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Maybe you want to consider add it to the workplace settings? In VScode it's just right click-spelling-Add words to workplace settings. I think it make sense to consider some package-specific terminologies like this, just like CONTCAR itself is not a word, but I still add it to VASP-related project workplaces to avoid being warned anyway.

@@ -177,8 +178,7 @@
fig = ptable_scatters(
data_dict, colormap="coolwarm", cbar_title="Periodic Table Scatter Plots"
)

save_and_compress_svg(fig, "ptable-scatters")
# save_and_compress_svg(fig, "ptable-scatters")
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Commented out by mistake I guess?

Copy link
Owner

Choose a reason for hiding this comment

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

yes, good catch! 👍

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I would remove the comment in a follow up ptable_scatter revision PR and I would see if I could accomplish those improvements as you suggested 😊.

@DanielYang59
Copy link
Collaborator Author

do you know of a solution?

I would see if I could do anything soon. Tomorrow would be the lunar new year ✨ so...happy Chinese new year and I would catch up soon.

@janosh
Copy link
Owner

janosh commented Feb 9, 2024

I would see if I could do anything soon. Tomorrow would be the lunar new year ✨ so...happy Chinese new year and I would catch up soon.

no worries, i'll go ahead and merge this now. we can always make improvements later

again, thanks so much for this contribution! 👍

@janosh janosh merged commit 0c80670 into janosh:main Feb 9, 2024
@DanielYang59 DanielYang59 deleted the ptable_scatter branch February 10, 2024 00:59
janosh added a commit that referenced this pull request Mar 28, 2025
* add ptable_hists example

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* copy ptable_hists and clean up comment

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* use colorbar instead of color bar

* add ptable_scatters

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* show y axis and ticks

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* update main readme to include ptable _scatters

* remove space in colormap/colorbar

* replace _ with -

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* set tick position to out

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* use explicit encoding and absolute path

* add ptable_scatters to __init__

* tweak comments

* add unit tests

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* allow data in np.array as suggested by @janosh

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* compress assets/ptable-(hists|scatters).svg

* fix ptable-hists, ptable-scatters SVG urls

* clean up outdated gitignore

* use shorter version of GH raw URLs

* breaking: remove return_axes from ptable_hists() and ptable_scatters()

seems of little use in hindsight

* refactor tests

* bump pre-commit hooks

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Janosh Riebesell <[email protected]>
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 matplotlib Concerning matplotlib-powered functions ptable Periodic table
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New plot type: ptable_scatter
2 participants