Skip to content

Commit

Permalink
add missing page, add scatter as alias
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoGorelli committed Aug 18, 2024
1 parent ec57fb0 commit 28ac596
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
7 changes: 7 additions & 0 deletions py-polars/docs/source/reference/series/plot.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
====
Plot
====

.. currentmodule:: polars

.. autoproperty:: Series.plot
3 changes: 2 additions & 1 deletion py-polars/polars/dataframe/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,8 @@ def plot(self) -> Plot:
`alt.Chart(df).mark_line().encode(**kwargs).interactive()`
- `df.plot.point(**kwargs)`
is shorthand for
`alt.Chart(df).mark_point().encode(**kwargs).interactive()`
`alt.Chart(df).mark_point().encode(**kwargs).interactive()` (and `plot.scatter` is
provided as an alias)
- `df.plot.bar(**kwargs)`
is shorthand for
`alt.Chart(df).mark_bar().encode(**kwargs).interactive()`
Expand Down
3 changes: 3 additions & 0 deletions py-polars/polars/dataframe/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,9 @@ def point(
.interactive()
)

# Alias to `point` because of how common it is.
scatter = point

def __getattr__(self, attr: str) -> Callable[..., alt.Chart]:
method = getattr(self.chart, f"mark_{attr}", None)
if method is None:
Expand Down
1 change: 1 addition & 0 deletions py-polars/tests/unit/operations/namespaces/test_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def test_series_plot() -> None:
s.plot.hist().to_json()
s.plot.line().to_json()
s.plot.point().to_json()
s.plot.scatter().to_json()


def test_empty_dataframe() -> None:
Expand Down

0 comments on commit 28ac596

Please sign in to comment.