diff --git a/py-polars/polars/dataframe/plotting.py b/py-polars/polars/dataframe/plotting.py index eed8fbc62faf..75a2b92aa09e 100644 --- a/py-polars/polars/dataframe/plotting.py +++ b/py-polars/polars/dataframe/plotting.py @@ -31,9 +31,9 @@ def _maybe_extract_shorthand(encoding: Encoding) -> Encoding: - if isinstance(encoding, alt.SchemaBase) and hasattr(encoding, "shorthand"): + if isinstance(encoding, alt.SchemaBase): # e.g. for `alt.X('x:Q', axis=alt.Axis(labelAngle=30))`, return `'x:Q'` - return encoding.shorthand + return getattr(encoding, "shorthand", encoding) return encoding