diff --git a/doc/changelog.qmd b/doc/changelog.qmd index 96fee91a6..eec91ca3a 100644 --- a/doc/changelog.qmd +++ b/doc/changelog.qmd @@ -414,7 +414,7 @@ not exist, got no description. This release is fixes error. - You can now align the `plot_title` horizontally to the left or right. ```py - theme(plot_title=element_text(ha='left')) + theme(plot_title=element_text(ha="left")) ``` Before, the title was always centered. @@ -584,7 +584,7 @@ not exist, got no description. This release is fixes error. - Fixed issue where a plot has no data and the geoms have no data, but the mappings are valid. ({{< issue 404 >}}) -- Fixed `preserve='single'` in [](:class:`~plotnine.position_dodge`) +- Fixed `preserve="single"` in [](:class:`~plotnine.position_dodge`) and [](:class:`~plotnine.position_dodge2`) to work for geoms that only have `x` aesthetic and not `xmin` and `xmax` e.g [](:class:`~plotnine.geom_text`). @@ -631,7 +631,7 @@ not exist, got no description. This release is fixes error. scale. - Fixed [](:class:`~plotnine.geom_violin`) and other geoms when used - with `position='dodge'` not to crash when if a layer has an empty + with `position="dodge"` not to crash when if a layer has an empty group of data. - Fixed bug in [](:class:`~plotnine.geom_path`) for some cases when groups @@ -640,7 +640,7 @@ not exist, got no description. This release is fixes error. - Fixed all stats that compute kernel density estimates to work when all the data points are the same. ({{< issue 317 >}}) -- Fixed issue where setting the group to a string value i.e. `group='string'` +- Fixed issue where setting the group to a string value i.e. `group="string"` outside `aes()` failed due to an error. - Fixed issue where discrete position scales could not deal with fewer limits @@ -910,7 +910,7 @@ not exist, got no description. This release is fixes error. - Fixed bug in discrete scales where a column could not be mapped to integer values. ({{< issue 108 >}}) -- Make it possible to hide the legend with `theme(legend_position='none')`. +- Make it possible to hide the legend with `theme(legend_position="none")`. ({{< issue 119 >}}) - Fixed issue in [](:class:`~plotnine.stat_summary_bin`) where some input @@ -922,8 +922,8 @@ not exist, got no description. This release is fixes error. - Fixed `IndexError` in [](:class:`~plotnine.facet_grid`) when row/column variable has 1 unique value. ({{< issue 129 >}}) -- Fixed [](:class:`~plotnine.facet_grid`) when `scale='free'`, - `scale='free_x'` or `scale='free_y'`, the panels share axes +- Fixed [](:class:`~plotnine.facet_grid`) when `scale="free"`, + `scale="free_x"` or `scale="free_y"`, the panels share axes along the row or column. - Fixed [](:class:`~plotnine.geom_boxplot`) so that user can create a boxplot @@ -1071,7 +1071,7 @@ not exist, got no description. This release is fixes error. *(2017-06-22)* - Fixed bug where manually setting the aesthetic `fill=None` or - `fill='None'` could lead to a black fill instead of an empty + `fill="None"` could lead to a black fill instead of an empty fill. - Fixed bug where computed aesthetics could not be used in larger @@ -1083,7 +1083,7 @@ not exist, got no description. This release is fixes error. - Fixed bug where `ggplot(data=df)`{.py} resulted in an exception. - Fixed missing axis ticks and labels for [](:class:`~plotnine.facet_wrap`) - when the scales are allowed to vary (e.g `scales='free'`) between + when the scales are allowed to vary (e.g `scales="free"`) between the panels. - Fixed bug in [](:class:`~plotnine.stat_density`) where changing the diff --git a/plotnine/facets/facet.py b/plotnine/facets/facet.py index c254b8695..b267a1214 100644 --- a/plotnine/facets/facet.py +++ b/plotnine/facets/facet.py @@ -417,7 +417,7 @@ def make_figure(self) -> tuple[Figure, list[Axes]]: if not self.as_table: axsarr = np.array([row[::-1] for row in axsarr]) else: - raise ValueError(f"Bad value `dir='{self.dir}'` for direction") + raise ValueError(f'Bad value `dir="{self.dir}"` for direction') axs = axsarr.ravel(order) diff --git a/plotnine/facets/layout.py b/plotnine/facets/layout.py index d617e4619..b523d52c6 100644 --- a/plotnine/facets/layout.py +++ b/plotnine/facets/layout.py @@ -91,9 +91,9 @@ def train_position(self, layers: Layers, scales: Scales): Notes ----- The number of x or y scales depends on the facetting, - particularly the scales parameter. e.g if `scales='free'` + particularly the scales parameter. e.g if `scales="free"`{.py} then each panel will have separate x and y scales, and - if `scales='fixed'` then all panels will share an x + if `scales="fixed"`{.py} then all panels will share an x scale and a y scale. """ layout = self.layout diff --git a/plotnine/geoms/annotate.py b/plotnine/geoms/annotate.py index 659a06b76..13ad7b375 100644 --- a/plotnine/geoms/annotate.py +++ b/plotnine/geoms/annotate.py @@ -56,7 +56,7 @@ class annotate: You should choose or ignore accordingly. - All `geoms` are created with `stat='identity'`{.py}. + All `geoms` are created with `stat="identity"`{.py}. """ _annotation_geom: geom_base_class diff --git a/plotnine/geoms/geom.py b/plotnine/geoms/geom.py index b91ec230b..25b8741e8 100644 --- a/plotnine/geoms/geom.py +++ b/plotnine/geoms/geom.py @@ -53,7 +53,7 @@ class geom(ABC, metaclass=Register): """Geom/layer specific dataframe""" mapping: aes - """Mappings i.e. `aes(x='col1', fill='col2')`{.py}""" + """Mappings i.e. `aes(x="col1", fill="col2")`{.py}""" aes_params: dict[str, Any] = {} # setting of aesthetic params: dict[str, Any] # parameter settings @@ -379,8 +379,8 @@ def draw_unit( Plot data belonging to a unit. A matplotlib plot function may require that an aethestic - have a single unique value. e.g. linestyle='dashed' and - not linestyle=['dashed', 'dotted', ...]. + have a single unique value. e.g. `linestyle="dashed"`{.py} + and not `linestyle=["dashed", "dotted", ...]`{.py}. A single call to such a function can only plot lines with the same linestyle. However, if the plot we want has more than one line with different linestyles, we need to group diff --git a/plotnine/geoms/geom_boxplot.py b/plotnine/geoms/geom_boxplot.py index b6711a751..c219ce7d0 100644 --- a/plotnine/geoms/geom_boxplot.py +++ b/plotnine/geoms/geom_boxplot.py @@ -109,7 +109,7 @@ def __init__( _position = kwargs.get("position", self.DEFAULT_PARAMS["position"]) varwidth = kwargs.get("varwidth", self.DEFAULT_PARAMS["varwidth"]) - # varwidth = True is not compatible with preserve='total' + # varwidth = True is not compatible with preserve="total" if varwidth: if isinstance(_position, str): kwargs["position"] = position_dodge2(preserve="single") diff --git a/plotnine/geoms/geom_dotplot.py b/plotnine/geoms/geom_dotplot.py index 27391a0b5..fca2c1f47 100644 --- a/plotnine/geoms/geom_dotplot.py +++ b/plotnine/geoms/geom_dotplot.py @@ -71,7 +71,7 @@ def setup_data(self, data: pd.DataFrame) -> pd.DataFrame: # Issue warnings when parameters don't make sense if gp["position"] == "stack": warn( - "position='stack' doesn't work properly with " + 'position="stack" doesn"t work properly with ' "geom_dotplot. Use stackgroups=True instead.", PlotnineWarning, ) @@ -82,8 +82,8 @@ def setup_data(self, data: pd.DataFrame) -> pd.DataFrame: ): warn( "geom_dotplot called with stackgroups=TRUE and " - "method='dotdensity'. You probably want to set " - "binpositions='all'", + 'method="dotdensity". You probably want to set ' + 'binpositions="all"', PlotnineWarning, ) diff --git a/plotnine/geoms/geom_ribbon.py b/plotnine/geoms/geom_ribbon.py index ba01ad950..242412ed4 100644 --- a/plotnine/geoms/geom_ribbon.py +++ b/plotnine/geoms/geom_ribbon.py @@ -52,11 +52,11 @@ class geom_ribbon(geom): expression should match the `ymin` value or expression. i.e. ```python - aes(ymin=0, ymax='col1', where='col1 > 0') # good - aes(ymin=0, ymax='col1', where='col1 > 10') # bad + aes(ymin=0, ymax="col1", where="col1 > 0") # good + aes(ymin=0, ymax="col1", where="col1 > 10") # bad - aes(ymin=col2, ymax='col1', where='col1 > col2') # good - aes(ymin=col2, ymax='col1', where='col1 > col3') # bad + aes(ymin=col2, ymax="col1", where="col1 > col2") # good + aes(ymin=col2, ymax="col1", where="col1 > col3") # bad ``` """ DEFAULT_AES = { diff --git a/plotnine/ggplot.py b/plotnine/ggplot.py index 1c90f80e1..85f94073d 100755 --- a/plotnine/ggplot.py +++ b/plotnine/ggplot.py @@ -728,9 +728,9 @@ def myplots(): def facet_pages(column) base_plot = [ - aes(x='wt', y='mpg', label='name'), + aes(x="wt", y="mpg", label="name"), geom_text(), - ] + ] for label, group_data in mtcars.groupby(column): yield ggplot(group_data) + base_plot + ggtitle(label) diff --git a/plotnine/guides/guide_legend.py b/plotnine/guides/guide_legend.py index 0d608a023..e582fdb2f 100644 --- a/plotnine/guides/guide_legend.py +++ b/plotnine/guides/guide_legend.py @@ -124,7 +124,7 @@ def merge(self, other): ```python from ggplot import * p = ( - ggplot(aes(x='cut', fill='cut', color='cut'), data=diamonds) + ggplot(aes(x="cut", fill="cut", color="cut"), data=diamonds) + stat_bin() ) ``` diff --git a/plotnine/scales/limits.py b/plotnine/scales/limits.py index f008b4175..f604f417e 100644 --- a/plotnine/scales/limits.py +++ b/plotnine/scales/limits.py @@ -50,9 +50,9 @@ def get_scale(self, plot): # aesthetic is mapped to a categorical but the limits # are not provided in categorical form. We only handle # the case where the mapping uses an expression to - # conver to categorical e.g `aes(color='factor(cyl)')`. - # However if `'cyl'` column is a categorical and the - # mapping is `aes(color='cyl')`, that will result in + # conver to categorical e.g `aes(color="factor(cyl)")`. + # However if `"cyl"` column is a categorical and the + # mapping is `aes(color="cyl")`, that will result in # an error. If later case proves common enough then we # could inspect the data and be clever based on that too!! ae = self.aesthetic diff --git a/plotnine/stats/smoothers.py b/plotnine/stats/smoothers.py index 24e55bb3c..90ef37e56 100644 --- a/plotnine/stats/smoothers.py +++ b/plotnine/stats/smoothers.py @@ -368,7 +368,7 @@ def loess(data, xseq, **params): kwargs["surface"] = "direct" warnings.warn( "Making prediction outside the data range, " - "setting loess control parameter `surface='direct'`.", + 'setting loess control parameter `surface="direct"`.', PlotnineWarning, ) diff --git a/plotnine/stats/stat_bindot.py b/plotnine/stats/stat_bindot.py index 1bcba3248..ed427645d 100644 --- a/plotnine/stats/stat_bindot.py +++ b/plotnine/stats/stat_bindot.py @@ -38,13 +38,13 @@ class stat_bindot(stat): Number of bins. Overridden by binwidth. If `None`{.py}, a number is computed using the freedman-diaconis method. binwidth : float, default=None - When `method='dotdensity'`{.py}, this specifies the maximum - binwidth. When `method='histodot'`{.py}, this specifies the + When `method="dotdensity"`{.py}, this specifies the maximum + binwidth. When `method="histodot"`{.py}, this specifies the binwidth. This supercedes the `bins`. origin : float, default=None - When `method='histodot'`{.py}, origin of the first bin. + When `method="histodot"`{.py}, origin of the first bin. width : float, default=0.9 - When `binaxis='y'`{.py}, the spacing of the dotstacks for + When `binaxis="y"`{.py}, the spacing of the dotstacks for dodging. binaxis : Literal["x", "y"], default="x" Axis to bin along. @@ -60,10 +60,10 @@ class stat_bindot(stat): drop : bool, default=False If `True`{.py}, remove all bins with zero counts. right : bool, default=True - When `method='histodot'`{.py}, `True`{.py} means include right + When `method="histodot"`{.py}, `True`{.py} means include right edge of the bins and if `False`{.py} the left edge is included. breaks : FloatArray, default=None - Bin boundaries for `method='histodot'`{.py}. This supercedes the + Bin boundaries for `method="histodot"`{.py}. This supercedes the `binwidth` and `bins`. See Also diff --git a/plotnine/stats/stat_sina.py b/plotnine/stats/stat_sina.py index 1bef0a91e..f7aa6c730 100644 --- a/plotnine/stats/stat_sina.py +++ b/plotnine/stats/stat_sina.py @@ -47,7 +47,7 @@ class stat_sina(stat): bin_limit : int, default=1 If the samples within the same y-axis bin are more than `bin_limit`, the samples's X coordinates will be adjusted. - This parameter is effective only when `method='counts'`{.py} + This parameter is effective only when `method="counts"`{.py} random_state : int | ~numpy.random.RandomState, default=None Seed or Random number generator to use. If `None`, then numpy global generator [](`numpy.random`) is used. diff --git a/plotnine/stats/stat_ydensity.py b/plotnine/stats/stat_ydensity.py index 3ce66a9d1..eceac0a8a 100644 --- a/plotnine/stats/stat_ydensity.py +++ b/plotnine/stats/stat_ydensity.py @@ -19,7 +19,7 @@ class stat_ydensity(stat): Parameters ---------- {common_parameters} - kernel : str, default='gaussian' + kernel : str, default="gaussian" Kernel used for density estimation. One of: ```python diff --git a/tests/test_facets.py b/tests/test_facets.py index 259f399b0..dc6e9dd0c 100644 --- a/tests/test_facets.py +++ b/tests/test_facets.py @@ -190,7 +190,7 @@ def test_array_mapping_and_evaluation(): {"x": range(12), "y": range(12), "g": list("abcd") * 3} ) - # should be the same as if color='g' + # should be the same as if color="g" p = ( ggplot(data, aes("x", "y", color=data["g"])) + geom_point(size=4)