pola-rs/polars · error · AttributeError
Altair has no method 'mark_
Error message
Altair has no method 'mark_{attr}' What it means
SeriesPlot.__getattr__ resolves the attribute to an Altair mark_{attr} method. If Altair's Chart has no such mark method, it raises AttributeError('Altair has no method mark_{attr}'). This guards against typos and unsupported mark names for the installed Altair version.
Solutions
- Check dir(alt.Chart) for available mark_* methods
- Use a valid Altair mark: bar, point, line, area, circle, tick, rule, rect, arc
- Remember scatter is aliased: s.plot.scatter() maps to mark_point
- Upgrade Altair if the mark you need exists only in newer versions
Example fix
// before s.plot.barchart() // after s.plot.bar() # Altair mark_bar
Defensive patterns
Strategy: validation
Validate before calling
import altair as alt
if not hasattr(alt.Chart, f"mark_{attr}"):
raise ValueError(f"unknown mark: {attr}")
getattr(s.plot, attr)() Type guard
def is_valid_mark(attr: str) -> bool:
import altair as alt
return hasattr(alt.Chart, f"mark_{attr}") Try / catch
try:
chart = s.plot.barchart()
except AttributeError as e:
if "Altair has no method" in str(e):
chart = s.plot.bar() # fall back to a valid mark Prevention
- Use Altair mark names (bar, point, line, area, circle, rect, arc, tick)
- Remember scatter is the only alias (to point)
- Check installed Altair version — marks vary across versions
- List valid marks with [m for m in dir(alt.Chart) if m.startswith('mark_')]
When it happens
Trigger: Calling s.plot.barchart(), s.plot.barh(), s.plot.lines(), or any misspelled/unsupported mark name like s.plot.sactter() where f'mark_{attr}' doesn't exist on alt.Chart.
Common situations: Expecting pandas-bokeh/matplotlib-style plot method names; Altair version differences where newer marks (e.g. mark_arc in older versions) don't exist; typos like s.plot.pointt().
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- altair>=5.4.0 is required for `.plot`
- Altair has no method 'mark_
- Cannot call `plot. ` when Series name is 'index
- cannot call `plot.line` when Series name is 'index'
- cannot use `plot.hist` when Series name is `'count()'`
AI-assisted analysis of pola-rs/polars@fe841f959e (2026-09-18).
Data as JSON: /api/errors/d1ae5ef2f3ae0088.
Report an issue: GitHub.
Appendix: source
Thrown at py-polars/src/polars/series/plotting.py:177
encodings: Encodings = {"x": "index", "y": self._series_name}
return (
alt.Chart(self._df.with_row_index())
.mark_line(tooltip=True)
.encode(**encodings, **kwargs)
.interactive()
)
def __getattr__(self, attr: str) -> Callable[..., alt.Chart]:
if self._series_name == "index":
msg = f"Cannot call `plot.{attr}` when Series name is 'index'"
raise ValueError(msg)
if attr == "scatter":
# alias `scatter` to `point` because of how common it is
attr = "point"
method = getattr(alt.Chart(self._df.with_row_index()), f"mark_{attr}", None)
if method is None:
msg = f"Altair has no method 'mark_{attr}'"
raise AttributeError(msg)
encodings: Encodings = {"x": "index", "y": self._series_name}
accepts_tooltip_argument = "tooltip" in {
value.name for value in inspect.signature(method).parameters.values()
}
if accepts_tooltip_argument:
def func(**kwargs: EncodeKwds) -> alt.Chart:
return method(tooltip=True).encode(**encodings, **kwargs).interactive()
else:
def func(**kwargs: EncodeKwds) -> alt.Chart:
return method().encode(**encodings, **kwargs).interactive()
return func
View on GitHub (pinned to fe841f959e)