Skip to content

fix: DataFrame plot was raising when some extra keywords were passed to encodings (e.g. x=alt.X(a, axis=alt.Axis(labelAngle=30)))#18836

Merged
ritchie46 merged 2 commits intopola-rs:mainfrom
MarcoGorelli:plot-x-with-axis
Sep 23, 2024
Merged

fix: DataFrame plot was raising when some extra keywords were passed to encodings (e.g. x=alt.X(a, axis=alt.Axis(labelAngle=30)))#18836
ritchie46 merged 2 commits intopola-rs:mainfrom
MarcoGorelli:plot-x-with-axis

Conversation

@MarcoGorelli
Copy link
Copy Markdown
Collaborator

@MarcoGorelli MarcoGorelli commented Sep 20, 2024

closes #18830

cc @dangotbanned in case you have time/interest to take a look

Summary: the solution used in #18625 breaks if some extra options (e.g. sort, axis) are specified to the encode arguments. What I'm proposing is to extract 'shorthand' in such cases, so that the tooltips can keep being shown by default

@github-actions github-actions Bot added fix Bug fix python Related to Python Polars rust Related to Rust Polars labels Sep 20, 2024
…to encodings (e.g. `x=alt.X(a, axis=alt.Axis(labelAngle=30))`)
@codecov
Copy link
Copy Markdown

codecov Bot commented Sep 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79.86%. Comparing base (2b4986a) to head (e8b5ffd).
Report is 16 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #18836   +/-   ##
=======================================
  Coverage   79.86%   79.86%           
=======================================
  Files        1518     1518           
  Lines      205610   205641   +31     
  Branches     2893     2894    +1     
=======================================
+ Hits       164202   164236   +34     
+ Misses      40860    40857    -3     
  Partials      548      548           

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

Comment thread py-polars/polars/dataframe/plotting.py Outdated


def _maybe_extract_shorthand(encoding: Encoding) -> Encoding:
if isinstance(encoding, alt.SchemaBase) and hasattr(encoding, "shorthand"):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Will try to look at this properly tomorrow @MarcoGorelli

This could be a source of false positives, you may be safer using inspect.getattr_static
https://docs.python.org/3/library/inspect.html#fetching-attributes-statically

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

thanks @dangotbanned !

the value does need returning, so maybe just using getattr directly is fine?

@ritchie46
Copy link
Copy Markdown
Member

Alright, I will already merge to include in todays release. Can be improved upon later ofcourse!

@ritchie46 ritchie46 merged commit 262f7bc into pola-rs:main Sep 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Bug fix python Related to Python Polars rust Related to Rust Polars

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: plotting breaks when axis is passed to alt.X

3 participants