From 52211d4533c891863267149ee9331720ee705fad Mon Sep 17 00:00:00 2001 From: Hassan Kibirige Date: Mon, 17 Jun 2024 15:29:21 +0300 Subject: [PATCH] Accept title & subtitle kwargs for ggtitle closes #804 --- doc/changelog.qmd | 3 +++ plotnine/labels.py | 15 ++++++--------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/doc/changelog.qmd b/doc/changelog.qmd index 88198c4a4..a96106016 100644 --- a/doc/changelog.qmd +++ b/doc/changelog.qmd @@ -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. ({{}}) + ### New Features - [](:class:`~plotnine.geom_text`) has gained new aesthetics diff --git a/plotnine/labels.py b/plotnine/labels.py index bffe4322d..3cb357d42 100644 --- a/plotnine/labels.py +++ b/plotnine/labels.py @@ -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): @@ -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): @@ -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)