{"record":{"id":"d1ae5ef2f3ae0088","repo":"pola-rs/polars","slug":"altair-has-no-method-mark-attr-d1ae5e","errorCode":null,"errorMessage":"Altair has no method 'mark_{attr}'","messagePattern":"Altair has no method 'mark_(.+?)'","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/series/plotting.py","lineNumber":177,"sourceCode":"        encodings: Encodings = {\"x\": \"index\", \"y\": self._series_name}\n        return (\n            alt.Chart(self._df.with_row_index())\n            .mark_line(tooltip=True)\n            .encode(**encodings, **kwargs)\n            .interactive()\n        )\n\n    def __getattr__(self, attr: str) -> Callable[..., alt.Chart]:\n        if self._series_name == \"index\":\n            msg = f\"Cannot call `plot.{attr}` when Series name is 'index'\"\n            raise ValueError(msg)\n        if attr == \"scatter\":\n            # alias `scatter` to `point` because of how common it is\n            attr = \"point\"\n        method = getattr(alt.Chart(self._df.with_row_index()), f\"mark_{attr}\", None)\n        if method is None:\n            msg = f\"Altair has no method 'mark_{attr}'\"\n            raise AttributeError(msg)\n        encodings: Encodings = {\"x\": \"index\", \"y\": self._series_name}\n\n        accepts_tooltip_argument = \"tooltip\" in {\n            value.name for value in inspect.signature(method).parameters.values()\n        }\n        if accepts_tooltip_argument:\n\n            def func(**kwargs: EncodeKwds) -> alt.Chart:\n                return method(tooltip=True).encode(**encodings, **kwargs).interactive()\n        else:\n\n            def func(**kwargs: EncodeKwds) -> alt.Chart:\n                return method().encode(**encodings, **kwargs).interactive()\n\n        return func\n","sourceCodeStart":159,"sourceCodeEnd":193,"githubUrl":"https://github.com/pola-rs/polars/blob/df599052daf96e7a9cc30a3b0c6bd25d6947e3c0/py-polars/src/polars/series/plotting.py#L159-L193","documentation":"Raised by SeriesPlot.__getattr__ (py-polars/src/polars/series/plotting.py:177) when the requested chart type has no corresponding Altair mark_* method. s.plot.<attr> dispatches to alt.Chart.mark_<attr>; if Altair defines no such mark, polars raises AttributeError listing the missing 'mark_<attr>' name. Note that 'scatter' is special-cased to 'point' before the lookup.","triggerScenarios":"s.plot.histogram() (Altair has no mark_histogram — use plot.hist), s.plot.boxplot() (the mark is mark_boxplot, so this actually works; but s.plot.box would not), s.plot.pie() (no mark_pie in Altair's standard API), or typos like s.plot.barr().","commonSituations":"Guessing chart-method names by analogy with other libraries (matplotlib/pandas: .hist(), .scatter(), .box()); typos; expecting every chart type to exist. The fix is to use the name Altair's mark_* methods define.","solutions":["Use a valid Altair mark name: plot.bar, plot.point (or plot.scatter alias), plot.line, plot.area, plot.tick, plot.rect, plot.boxplot","For histograms use the dedicated method: s.plot.hist() instead of s.plot.histogram()","Check Altair docs for the full mark_* list your installed version supports"],"exampleFix":"# before\ns.plot.histogram()  # AttributeError: Altair has no method 'mark_histogram'\n\n# after\ns.plot.hist()\n# generic marks:\ns.plot.bar()","handlingStrategy":"validation","validationCode":"import altair as alt\n\nMARKS = {m.removeprefix(\"mark_\") for m in dir(alt.Chart) if m.startswith(\"mark_\")}\n\ndef plot_mark(s, mark: str, **kw):\n    mark = {\"scatter\": \"point\"}.get(mark, mark)\n    if mark not in MARKS:\n        raise ValueError(f\"unknown mark {mark!r}; choose from {sorted(MARKS)}\")\n    return getattr(s.plot, mark)(**kw)","typeGuard":null,"tryCatchPattern":"try:\n    chart = getattr(s.plot, mark)()\nexcept AttributeError as e:\n    if \"Altair has no method\" in str(e):\n        raise ValueError(f\"unsupported chart type {mark!r}; use hist/bar/point/line/area/tick/boxplot\") from e\n    raise","preventionTips":["Learn the Altair mark_* vocabulary — the plot method list mirrors it exactly","Use s.plot.hist() for histograms; s.plot.scatter is an alias for point"],"tags":["polars","plotting","altair","attributeerror","api-misuse"],"backgroundTag":null,"analyzedSha":"df599052daf96e7a9cc30a3b0c6bd25d6947e3c0","analyzedAt":"2026-08-16T12:10:03.978Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}