Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accept title & subtitle kwargs for ggtitle #806

Merged
merged 1 commit into from
Jun 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions doc/changelog.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ title: Changelog
- plotnine now responds to the `fig-width`, `fig-height` and `fig-format`
settings in the meta section of a quarto document.

- [](:class:`~plotnine.ggtitle`) now accepts `title` and `subtitle` as
keyword arguments. ({{<issue 804 >}})

### New Features

- [](:class:`~plotnine.geom_text`) has gained new aesthetics
Expand Down
15 changes: 6 additions & 9 deletions plotnine/labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,8 @@ class xlab(labs):
x aesthetic label (x-axis)
"""

def __init__(self, name: str, /):
self.x = name
self.labels = labels_view(x=name)
def __init__(self, label: str):
super().__init__(x=label)


class ylab(labs):
Expand All @@ -131,9 +130,8 @@ class ylab(labs):
y aesthetic label i.e. y-axis label
"""

def __init__(self, name: str, /):
self.y = name
self.labels = labels_view(y=name)
def __init__(self, label: str):
super().__init__(y=label)


class ggtitle(labs):
Expand All @@ -146,6 +144,5 @@ class ggtitle(labs):
Plot title
"""

def __init__(self, title: str, /):
self.title = title
self.labels = labels_view(title=title)
def __init__(self, title: str | None = None, subtitle: str | None = None):
super().__init__(title=title, subtitle=subtitle)