diff --git a/plotnine/animation.py b/plotnine/animation.py index 73e17b3bf..090f06ff3 100644 --- a/plotnine/animation.py +++ b/plotnine/animation.py @@ -28,17 +28,17 @@ class PlotnineAnimation(ArtistAnimation): Parameters ---------- - plots : iterable + plots : ggplot objects that make up the the frames of the animation - interval : number, optional + interval : int Delay between frames in milliseconds. Defaults to 200. - repeat_delay : number, optional + repeat_delay : int If the animation in repeated, adds a delay in milliseconds before repeating the animation. Defaults to `None`. - repeat : bool, optional + repeat : bool Controls whether the animation should repeat when the sequence of frames is completed. Defaults to `True`. - blit : bool, optional + blit : bool Controls whether blitting is used to optimize drawing. Defaults to `False`. diff --git a/plotnine/coords/coord_fixed.py b/plotnine/coords/coord_fixed.py index 061c24bd8..9ae9c63b4 100644 --- a/plotnine/coords/coord_fixed.py +++ b/plotnine/coords/coord_fixed.py @@ -19,11 +19,11 @@ class coord_fixed(coord_cartesian): ---------- ratio : float Desired aspect_ratio (:math:`y/x`) of the panel(s). - xlim : tuple[float, float], default=None + xlim : tuple[float, float] Limits for x axis. If None, then they are automatically computed. - ylim : tuple[float, float], default=None + ylim : tuple[float, float] Limits for y axis. If None, then they are automatically computed. - expand : bool, default=True + expand : bool If `True`, expand the coordinate axes by some factor. If `False`, use the limits from the data. diff --git a/plotnine/coords/coord_trans.py b/plotnine/coords/coord_trans.py index f49e7a9a3..97bbc1a7e 100644 --- a/plotnine/coords/coord_trans.py +++ b/plotnine/coords/coord_trans.py @@ -35,11 +35,11 @@ class coord_trans(coord): Name of transform or `trans` class to transform the x axis y : str | trans Name of transform or `trans` class to transform the y axis - xlim : tuple[float, float], default=None + xlim : tuple[float, float] Limits for x axis. If None, then they are automatically computed. - ylim : tuple[float, float], default=None + ylim : tuple[float, float] Limits for y axis. If None, then they are automatically computed. - expand : bool, default=True + expand : bool If `True`, expand the coordinate axes by some factor. If `False`, use the limits from the data. """ diff --git a/plotnine/doctools.py b/plotnine/doctools.py index bd08218f7..e3f8f92bf 100644 --- a/plotnine/doctools.py +++ b/plotnine/doctools.py @@ -54,7 +54,7 @@ AESTHETICS_TABLE_TPL = """ {table} -The **bold** aesthetics are required.""" +The _emphasized_ aesthetics are required.""" STAT_SIGNATURE_TPL = """ **Usage** @@ -106,15 +106,15 @@ {_aesthetics_doc} data : dataframe, default=None {data} -stat : str or stat, default={default_stat} +stat : str | stat, default="{default_stat}" {stat} -position : str or position, default={default_position} +position : str | position, default="{default_position}" {position} na_rm : bool, default={default_na_rm} {na_rm} inherit_aes : bool, default={default_inherit_aes} {inherit_aes} -show_legend : bool or dict, default=None +show_legend : bool | dict, default=None {show_legend} raster : bool, default={default_raster} {raster} @@ -126,9 +126,9 @@ {_aesthetics_doc} data : dataframe, default=None {data} -geom : str or geom, default={default_geom} +geom : str | geom, default="{default_geom}" {stat} -position : str or position, default={default_position} +position : str | position, default="{default_position}" {position} na_rm : bool, default={default_na_rm} {na_rm} @@ -291,7 +291,7 @@ def param_spec(line: str) -> str | None: Returns ------- - name : str or None + name : str | None Name of the parameter if the line for the parameter type specification and None otherwise. @@ -412,7 +412,7 @@ def document_geom(geom: type[Geom]) -> type[Geom]: usage = GEOM_SIGNATURE_TPL.format(signature=signature) # aesthetics - contents = {f"**{ae}**": "" for ae in sorted(geom.REQUIRED_AES)} + contents = {f"_{ae}_": "" for ae in sorted(geom.REQUIRED_AES)} if geom.DEFAULT_AES: d = geom.DEFAULT_AES.copy() d["group"] = "" # All geoms understand the group aesthetic diff --git a/plotnine/facets/facet.py b/plotnine/facets/facet.py index b9e3931f2..eddd26e58 100644 --- a/plotnine/facets/facet.py +++ b/plotnine/facets/facet.py @@ -40,7 +40,7 @@ class facet: Parameters ---------- - scales : "fixed", "free", "free_x", "free_y", default="fixed" + scales : "fixed" | "free" | "free_x" | "free_y", default="fixed" Whether `x` or `y` scales should be allowed (free) to vary according to the data on each of the panel. shrink : bool @@ -49,7 +49,7 @@ class facet: shrink : bool, default=True Whether to shrink the scales to the output of the statistics instead of the raw data. - labeller : str, callable, default="label_value" + labeller : str | callable, default="label_value" How to label the facets. A string value if it should be one of `["label_value", "label_both", "label_context"]`{.py}. as_table : bool, default=True @@ -62,12 +62,12 @@ class facet: will automatically be dropped. If `False`, all factor levels will be shown, regardless of whether or not they appear in the data. - dir : "h", "v", default="h" + dir : "h" | "v", default="h" Direction in which to layout the panels. `h` for horizontal and `v` for vertical. """ - #: number of columns + # , number of columns ncol: int #: number of rows nrow: int diff --git a/plotnine/facets/facet_grid.py b/plotnine/facets/facet_grid.py index f84bd776f..44e190b1e 100644 --- a/plotnine/facets/facet_grid.py +++ b/plotnine/facets/facet_grid.py @@ -59,13 +59,15 @@ class facet_grid(facet): The size also depends to the `scales` parameter. If a string, it should be one of - ``['fixed', 'free', 'free_x', 'free_y']``. Currently, only the - ``'fixed'`` option is supported. + `['fixed', 'free', 'free_x', 'free_y']`{.py}. + Currently, only the `'fixed'` option is supported. Alternatively if a `dict`, it indicates the relative facet - size ratios such as:: + size ratios such as: - {'x': [1, 2], 'y': [3, 1, 1]} + ```python + {"x": [1, 2], "y": [3, 1, 1]} + ``` This means that in the horizontal direction, the second panel will be twice the length of the first. In the vertical direction @@ -74,11 +76,10 @@ class facet_grid(facet): Note that the number of dimensions in the list must equal the number of facets that will be produced. - shrink : bool, default=True Whether to shrink the scales to the output of the statistics instead of the raw data. - labeller : str, callable, default="label_value" + labeller : str | callable, default="label_value" How to label the facets. A string value if it should be one of `["label_value", "label_both", "label_context"]`{.py}. as_table : bool, default=True diff --git a/plotnine/facets/facet_wrap.py b/plotnine/facets/facet_wrap.py index 59d72eca1..c95c11664 100644 --- a/plotnine/facets/facet_wrap.py +++ b/plotnine/facets/facet_wrap.py @@ -31,7 +31,7 @@ class facet_wrap(facet): Parameters ---------- - facets : str| tuple + facets : str | tuple Variables to groupby and plot on different panels. If a string formula is used it should be right sided, e.g `"~ a + b"`, `("a", "b")` @@ -39,13 +39,13 @@ class facet_wrap(facet): Number of rows ncol : int, default=None Number of columns - scales : "fixed", "free", "free_x", "free_y", default="fixed" + scales : "fixed" | "free" | "free_x" | "free_y", default="fixed" Whether `x` or `y` scales should be allowed (free) to vary according to the data on each of the panel. shrink : bool, default=True Whether to shrink the scales to the output of the statistics instead of the raw data. - labeller : str, callable, default="label_value" + labeller : str | callable, default="label_value" How to label the facets. A string value if it should be one of `["label_value", "label_both", "label_context"]`{.py}. as_table : bool, default=True @@ -58,7 +58,7 @@ class facet_wrap(facet): will automatically be dropped. If `False`, all factor levels will be shown, regardless of whether or not they appear in the data. - dir : "h", "v", default="h" + dir : "h" | "v", default="h" Direction in which to layout the panels. `h` for horizontal and `v` for vertical. """ diff --git a/plotnine/facets/labelling.py b/plotnine/facets/labelling.py index 18d6e7a4f..037666c16 100644 --- a/plotnine/facets/labelling.py +++ b/plotnine/facets/labelling.py @@ -54,7 +54,7 @@ def label_both( Label information to be modified. multi_line : bool Whether to place each variable on a separate line - sep : str + sep : str Separation between variable name and value Returns @@ -88,7 +88,7 @@ def label_context( Label information multi_line : bool Whether to place each variable on a separate line - sep : str + sep : str Separation between variable name and value Returns @@ -120,9 +120,9 @@ def as_labeller( Parameters ---------- - x : function | dict + x : callable | dict Object to coerce - default : str | function + default : str | callable Default labeller. If it is a string, it should be the name of one the labelling functions provided by plotnine. @@ -153,13 +153,13 @@ class labeller: Parameters ---------- - rows : str, callable + rows : str | callable How to label the rows - cols : str, callable + cols : str | callable How to label the columns multi_line : bool Whether to place each variable on a separate line - default : str, callable + default : str | callable Fallback labelling function. If it is a string, it should be one of `["label_value", "label_both", "label_context"]`{.py}. kwargs : dict diff --git a/plotnine/geoms/annotate.py b/plotnine/geoms/annotate.py index 5416ae442..9154de1ad 100644 --- a/plotnine/geoms/annotate.py +++ b/plotnine/geoms/annotate.py @@ -22,7 +22,7 @@ class annotate: Parameters ---------- - geom : geom or str + geom : geom | str geom to use for annotation, or name of geom (e.g. 'point'). x : float Position diff --git a/plotnine/geoms/annotation_logticks.py b/plotnine/geoms/annotation_logticks.py index 6604db340..ab6e7cbff 100644 --- a/plotnine/geoms/annotation_logticks.py +++ b/plotnine/geoms/annotation_logticks.py @@ -77,11 +77,11 @@ def _check_log_scale( Parameters ---------- - base : float or None + base : float | None Base of the logarithm in which the ticks will be calculated. If `None`, the base of the log transform the scale will be used. - sides : str (default: bl) + sides : str, default="bl" Sides onto which to draw the marks. Any combination chosen from the characters `btlr`, for *bottom*, *top*, *left* or *right* side marks. If `coord_flip()` is used, @@ -251,23 +251,23 @@ class annotation_logticks(annotate): Parameters ---------- - sides : str (default: bl) + sides : str, default="bl" Sides onto which to draw the marks. Any combination chosen from the characters `btlr`, for *bottom*, *top*, *left* or *right* side marks. If `coord_flip()` is used, these are the sides *after* the flip. - alpha : float (default: 1) + alpha : float, default=1) Transparency of the ticks - color : str | tuple (default: 'black') + color : str | tuple, default="black" Colour of the ticks size : float Thickness of the ticks - linetype : 'solid' | 'dashed' | 'dashdot' | 'dotted' | tuple - Type of line. Default is *solid*. - lengths: tuple (default (0.036, 0.0225, 0.012)) + linetype : "solid" | "dashed" | "dashdot" | "dotted" | tuple[float] + Type of line + lengths: tuple[float], default=(0.036, 0.0225, 0.012) length of the ticks drawn for full / half / tenth ticks relative to panel size - base : float (default: None) + base : float, default=None Base of the logarithm in which the ticks will be calculated. If `None`, the base used to log transform the scale will be used. diff --git a/plotnine/geoms/annotation_stripes.py b/plotnine/geoms/annotation_stripes.py index 16cc6b5d6..e71496c42 100644 --- a/plotnine/geoms/annotation_stripes.py +++ b/plotnine/geoms/annotation_stripes.py @@ -29,29 +29,28 @@ class annotation_stripes(annotate): Parameters ---------- fill : list-like - List of colors for the strips. The default is - `("#AAAAAA", "#CCCCCC")` - fill_range: 'cycle' | 'nocycle' | 'auto' | 'no' - How to fill stripes beyond the range of scale:: - - 'cycle' # keep cycling the colors of the - # stripes after the range ends - 'nocycle' # stop cycling the colors of the - # stripes after the range ends - 'auto' # 'cycle' for continuous scales and - # 'nocycle' for discrete scales. - 'no' # Do not add stripes passed the range - # passed the range of the scales - - Default is 'auto'. - direction : 'vertical' or 'horizontal' + List of colors for the strips. + fill_range: "cycle" | "nocycle" | "auto" | "no" + How to fill stripes beyond the range of scale: + + ```python + "cycle" # keep cycling the colors of the + # stripes after the range ends + "nocycle" # stop cycling the colors of the + # stripes after the range ends + "auto" # "cycle" for continuous scales and + # "nocycle" for discrete scales. + "no" # Do not add stripes passed the range + # passed the range of the scales + ``` + direction : "vertical" | "horizontal" Orientation of the stripes extend : tuple Range of the stripes. The default is (0, 1), top to bottom. The values should be in the range [0, 1]. **kwargs : dict Other aesthetic parameters for the rectangular stripes. - They include; *alpha*, *color*, *linetype*, and *size*. + They include; `alpha`, `color`, `linetype`, and `size`. """ def __init__( diff --git a/plotnine/geoms/geom.py b/plotnine/geoms/geom.py index 24e69b93b..03e008c08 100644 --- a/plotnine/geoms/geom.py +++ b/plotnine/geoms/geom.py @@ -318,19 +318,19 @@ def draw_panel( The scale information as may be required by the axes. At this point, that information is about ranges, ticks and labels. Attributes are of interest - to the geom are:: - - 'panel_params.x.range' # tuple - 'panel_params.y.range' # tuple + to the geom are: + ```python + "panel_params.x.range" # tuple + "panel_params.y.range" # tuple + ``` coord : coord - Coordinate (e.g. coord_cartesian) system of the - geom. + Coordinate (e.g. coord_cartesian) system of the geom. ax : axes Axes on which to plot. params : dict Combined parameters for the geom and stat. Also - includes the 'zorder'. + includes the `zorder`. """ for _, gdata in data.groupby("group"): gdata.reset_index(inplace=True, drop=True) @@ -356,19 +356,19 @@ def draw_group( The scale information as may be required by the axes. At this point, that information is about ranges, ticks and labels. Keys of interest to - the geom are:: - - 'x_range' # tuple - 'y_range' # tuple + the geom are: + ```python + "x_range" # tuple + "y_range" # tuple + ``` coord : coord - Coordinate (e.g. coord_cartesian) system of the - geom. + Coordinate (e.g. coord_cartesian) system of the geom. ax : axes Axes on which to plot. params : dict Combined parameters for the geom and stat. Also - includes the 'zorder'. + includes the `zorder`. """ msg = "The geom should implement this method." raise NotImplementedError(msg) @@ -404,16 +404,19 @@ def draw_unit( The scale information as may be required by the axes. At this point, that information is about ranges, ticks and labels. Keys of interest to - the geom are:: + the geom are: - 'x_range' # tuple - 'y_range' # tuple + ```python + "x_range" # tuple + "y_range" # tuple + ``` In rare cases a geom may need access to the x or y scales. - Those are available at:: - - 'scales' # SimpleNamespace + Those are available at: + ```python + "scales" # SimpleNamespace + ``` coord : coord Coordinate (e.g. coord_cartesian) system of the geom. @@ -421,7 +424,7 @@ def draw_unit( Axes on which to plot. params : dict Combined parameters for the geom and stat. Also - includes the 'zorder'. + includes the `zorder`. """ msg = "The geom should implement this method." raise NotImplementedError(msg) diff --git a/plotnine/geoms/geom_bar.py b/plotnine/geoms/geom_bar.py index a72ed2dbc..a9191f7da 100644 --- a/plotnine/geoms/geom_bar.py +++ b/plotnine/geoms/geom_bar.py @@ -20,7 +20,7 @@ class geom_bar(geom_rect): Parameters ---------- {common_parameters} - width : float, optional (default None) + width : float, default=None Bar width. If `None`{.py}, the width is set to `90%` of the resolution of the data. diff --git a/plotnine/geoms/geom_boxplot.py b/plotnine/geoms/geom_boxplot.py index 304898c32..2fe4fb870 100644 --- a/plotnine/geoms/geom_boxplot.py +++ b/plotnine/geoms/geom_boxplot.py @@ -53,7 +53,7 @@ class geom_boxplot(geom): has a width parameter, that takes precedence over this one. outlier_alpha : float, default=1 Transparency of the outlier points. - outlier_color : str, tuple, default=None + outlier_color : str | tuple, default=None Color of the outlier points. outlier_shape : str, default="o" Shape of the outlier points. An empty string hides the outliers. diff --git a/plotnine/geoms/geom_dotplot.py b/plotnine/geoms/geom_dotplot.py index ff44b5cf4..11714975a 100644 --- a/plotnine/geoms/geom_dotplot.py +++ b/plotnine/geoms/geom_dotplot.py @@ -28,10 +28,9 @@ class geom_dotplot(geom): Parameters ---------- - {commonparameters} - stackdir : str, default="up" + {common_parameters} + stackdir : "up" | "down" | "center", | "centerwhole", default="up" Direction in which to stack the dots. Options are - `['up', 'down', 'center', 'centerwhole']`{.py} stackratio : float, default=1 How close to stack the dots. If value is less than 1, the dots overlap, if greater than 1 they are spaced. @@ -45,7 +44,7 @@ class geom_dotplot(geom): plotnine.stats.statbindot """ - DEFAULTAES = {"alpha": 1, "color": "black", "fill": "black"} + DEFAULT_AES = {"alpha": 1, "color": "black", "fill": "black"} REQUIRED_AES = {"x", "y"} NON_MISSING_AES = {"size", "shape"} DEFAULT_PARAMS = { diff --git a/plotnine/geoms/geom_jitter.py b/plotnine/geoms/geom_jitter.py index 1dd25e037..20d24c6e2 100644 --- a/plotnine/geoms/geom_jitter.py +++ b/plotnine/geoms/geom_jitter.py @@ -31,7 +31,7 @@ class geom_jitter(geom_point): Proportion to jitter in vertical direction. The default value is that from [](`~plotnine.positions.position_jitter`). - random_state : int, ~numpy.random.RandomState, default=None + random_state : int | ~numpy.random.RandomState, default=None Seed or Random number generator to use. If `None`, then numpy global generator :class:`numpy.random` is used. diff --git a/plotnine/geoms/geom_path.py b/plotnine/geoms/geom_path.py index 55b6594c3..25e1ba9b5 100644 --- a/plotnine/geoms/geom_path.py +++ b/plotnine/geoms/geom_path.py @@ -33,9 +33,9 @@ class geom_path(geom): Parameters ---------- {common_parameters} - lineend : "butt", "round", "projecting", default="butt" + lineend : "butt" | "round" | "projecting", default="butt" Line end style. This option is applied for solid linetypes. - linejoin : "round", "miter", "bevel", default="round" + linejoin : "round" | "miter" | "bevel", default="round" Line join style. This option is applied for solid linetypes. arrow : ~plotnine.geoms.geom_path.arrow, default=None Arrow specification. Default is no arrow. @@ -223,10 +223,10 @@ class arrow: single edge. length : int | float of the edge in "inches" - ends : "last", "first", "both" + ends : "last" | "first" | "both" At which end of the line to draw the arrowhead - type : "open", "closed" + type : "open" | "closed" When it is closed, it is also filled """ @@ -263,11 +263,12 @@ def draw( The scale information as may be required by the axes. At this point, that information is about ranges, ticks and labels. Attributes are of interest - to the geom are:: - - 'panel_params.x.range' # tuple - 'panel_params.y.range' # tuple + to the geom are: + ```python + "panel_params.x.range" # tuple + "panel_params.y.range" # tuple + ``` coord : coord Coordinate (e.g. coord_cartesian) system of the geom. @@ -278,7 +279,7 @@ def draw( the arrows are per segment of the path params : dict Combined parameters for the geom and stat. Also - includes the 'zorder'. + includes the `zorder`. """ first = self.ends in ("first", "both") last = self.ends in ("last", "both") @@ -375,19 +376,18 @@ def get_paths( List of points that define the tails of the arrows. The arrow heads will be at x1, y1. If you need them at x2, y2 reverse the input. - panel_params : panel_view The scale information as may be required by the axes. At this point, that information is about ranges, ticks and labels. Attributes are of interest - to the geom are:: - - 'panel_params.x.range' # tuple - 'panel_params.y.range' # tuple + to the geom are: + ```python + "panel_params.x.range" # tuple + "panel_params.y.range" # tuple + ``` coord : coord - Coordinate (e.g. coord_cartesian) system of the - geom. + Coordinate (e.g. coord_cartesian) system of the geom. ax : axes Axes on which to plot. diff --git a/plotnine/geoms/geom_quantile.py b/plotnine/geoms/geom_quantile.py index 20aa253e1..ff06abb2b 100644 --- a/plotnine/geoms/geom_quantile.py +++ b/plotnine/geoms/geom_quantile.py @@ -12,9 +12,9 @@ class geom_quantile(geom_path): Parameters ---------- {common_parameters} - lineend : "butt", "round", "projecting", default="butt" + lineend : "butt" | "round" | "projecting", default="butt" Line end style. This option is applied for solid linetypes. - linejoin : "round", "miter", "bevel", default="round" + linejoin : "round" | "miter" | "bevel", default="round" Line join style. This option is applied for solid linetypes. """ diff --git a/plotnine/geoms/geom_ribbon.py b/plotnine/geoms/geom_ribbon.py index dd8b914c4..7bc80d0fe 100644 --- a/plotnine/geoms/geom_ribbon.py +++ b/plotnine/geoms/geom_ribbon.py @@ -30,12 +30,12 @@ class geom_ribbon(geom): Parameters ---------- {common_parameters} - outline_type : "upper", "lower", "both", "full", default="both" + outline_type : "upper" | "lower" | "both" | "full", default="both" How to stroke to outline of the region / area. - - `upper` - draw only upper bounding line - - `lower` - draw only lower bounding line - - `both` - draw both upper & lower bounding lines - - `full` - draw closed polygon around the area. + If `upper`, draw only upper bounding line. + If `lower`, draw only lower bounding line. + If `both`, draw both upper & lower bounding lines. + If `full`, draw closed polygon around the area. """ _aesthetics_doc = """ diff --git a/plotnine/geoms/geom_segment.py b/plotnine/geoms/geom_segment.py index 1d7cbb484..1b10fc1cc 100644 --- a/plotnine/geoms/geom_segment.py +++ b/plotnine/geoms/geom_segment.py @@ -30,7 +30,7 @@ class geom_segment(geom): Parameters ---------- {common_parameters} - lineend : "butt", "round", "projecting", default="butt" + lineend : "butt" | "round" | "projecting", default="butt" Line end style. This option is applied for solid linetypes. arrow : ~plotnine.geoms.geom_path.arrow, default=None Arrow specification. Default is no arrow. diff --git a/plotnine/geoms/geom_step.py b/plotnine/geoms/geom_step.py index 0419bda5f..69fde259a 100644 --- a/plotnine/geoms/geom_step.py +++ b/plotnine/geoms/geom_step.py @@ -28,7 +28,7 @@ class geom_step(geom_path): Parameters ---------- {common_parameters} - direction : "hv", "vh", "mid", default="hv" + direction : "hv" | "vh" | "mid", default="hv" horizontal-vertical steps, vertical-horizontal steps or steps half-way between adjacent x values. diff --git a/plotnine/geoms/geom_text.py b/plotnine/geoms/geom_text.py index 4694b3279..5a2739a8c 100644 --- a/plotnine/geoms/geom_text.py +++ b/plotnine/geoms/geom_text.py @@ -39,9 +39,9 @@ class geom_text(geom): [latex](http://matplotlib.org/users/usetex.html). family : str, default=None Font family. - fontweight : int, str, default="normal" + fontweight : int | str, default="normal" Font weight. - fontstyle : "normal", "italic", "oblique", default="normal" + fontstyle : "normal" | "italic" | "oblique", default="normal" Font style. nudge_x : float, default=0 Horizontal adjustment to apply to the text @@ -51,18 +51,18 @@ class geom_text(geom): Parameters to :class:`adjustText.adjust_text` will repel overlapping texts. This parameter takes priority of over `nudge_x` and `nudge_y`. - `adjust_text` does not work well when it is used in the first layer of the plot, or if it is the only layer. For more see the documentation at https://github.com/Phlya/adjustText/wiki . format_string : str, default=None If not `None`{.py}, then the text is formatted with this - string using :meth:`str.format` e.g:: - - # 2.348 -> "2.35%" - geom_text(format_string="{:.2f}%") + string using :meth:`str.format` e.g: + ```python + # 2.348 -> "2.35%" + geom_text(format_string="{:.2f}%") + ``` path_effects : list, default=None If not `None`{.py}, then the text will use these effects. See diff --git a/plotnine/geoms/geom_violin.py b/plotnine/geoms/geom_violin.py index aa18a7690..99a3ab389 100644 --- a/plotnine/geoms/geom_violin.py +++ b/plotnine/geoms/geom_violin.py @@ -28,7 +28,7 @@ class geom_violin(geom): Parameters ---------- {common_parameters} - draw_quantiles : float, list[float], default=None + draw_quantiles : float | list[float], default=None draw horizontal lines at the given quantiles (0..1) of the density estimate. style : str, default="full" diff --git a/plotnine/ggplot.py b/plotnine/ggplot.py index dae85cc53..2fdc83869 100755 --- a/plotnine/ggplot.py +++ b/plotnine/ggplot.py @@ -155,7 +155,7 @@ def __iadd__( Parameters ---------- - other : object or Sequence + other : object | Sequence Either an object that knows how to "radd" itself to a ggplot, or a list of such objects. """ @@ -174,7 +174,7 @@ def __add__(self, other: PlotAddable | list[PlotAddable] | None) -> ggplot: Parameters ---------- - other : object or Sequence + other : object | Sequence Either an object that knows how to "radd" itself to a ggplot, or a list of such objects. """ @@ -202,7 +202,7 @@ def draw(self, show: bool = False) -> Figure: Parameters ---------- - show : bool (default: False) + show : bool Whether to show the plot. Returns @@ -614,7 +614,7 @@ def save( Parameters ---------- - filename : str | pathlib.Path, optional + filename : str | pathlib.Path File name to write the plot to. If not specified, a name like “plotnine-save-.” is used. format : str @@ -623,10 +623,10 @@ def save( path : str Path to save plot to (if you just want to set path and not filename). - width : number, optional + width : number Width (defaults to value set by the theme). If specified the `height` must also be given. - height : number, optional + height : number Height (defaults to value set by the theme). If specified the `width` must also be given. units : str @@ -674,57 +674,67 @@ def save_as_pdf_pages( Parameters ---------- - plots : collection or generator of [](`~plotnine.ggplot`) + plots : Plot objects to write to file. `plots` may be either a collection such as a :py:class:`list` or :py:class:`set`: - >>> base_plot = ggplot(…) - >>> plots = [base_plot + ggtitle('%d of 3' % i) for i in range(1, 3)] - >>> save_as_pdf_pages(plots) + ```python + base_plot = ggplot(…) + plots = [base_plot + ggtitle('%d of 3' % i) for i in range(1, 3)] + save_as_pdf_pages(plots) + ``` or, a generator that yields [](`~plotnine.ggplot`) objects: - >>> def myplots(): - >>> for i in range(1, 3): - >>> yield ggplot(…) + ggtitle('%d of 3' % i) - >>> save_as_pdf_pages(myplots()) + ```python + def myplots(): + for i in range(1, 3): + yield ggplot(…) + ggtitle('%d of 3' % i) + save_as_pdf_pages(myplots()) + ``` - filename : :py:class:`str`, optional + filename : str File name to write the plot to. If not specified, a name like “plotnine-save-.pdf” is used. - path : :py:class:`str`, optional + path : str Path to save plot to (if you just want to set path and not filename). - verbose : :py:class:`bool` + verbose : bool If `True`, print the saving information. - kwargs : :py:class:`dict` + kwargs : dict Additional arguments to pass to :py:meth:`matplotlib.figure.Figure.savefig`. Notes ----- - Using pandas' :meth:`~pandas.DataFrame.groupby` methods, tidy data + Using pandas :meth:`~pandas.DataFrame.groupby` methods, tidy data can be “faceted” across pages: - >>> from plotnine.data import mtcars - >>> def facet_pages(column) - >>> base_plot = [ - >>> 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) - >>> save_as_pdf_pages(facet_pages('cyl')) + ```python + from plotnine.data import mtcars + + def facet_pages(column) + base_plot = [ + 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) + + save_as_pdf_pages(facet_pages('cyl')) + ``` Unlike :meth:`ggplot.save`, :meth:`save_as_pdf_pages` does not process arguments for `height` or `width`. To set the figure size, add [](`~plotnine.themes.themeable.figure_size`) to the theme for some or all of the objects in `plots`: - >>> plot = ggplot(…) - >>> # The following are equivalent - >>> plot.save('filename.pdf', height=6, width=8) - >>> save_as_pdf_pages([plot + theme(figure_size=(8, 6))]) + ```python + plot = ggplot(…) + # The following are equivalent + plot.save('filename.pdf', height=6, width=8) + save_as_pdf_pages([plot + theme(figure_size=(8, 6))]) + ``` """ from matplotlib.backends.backend_pdf import PdfPages @@ -766,9 +776,9 @@ class plot_context: ---------- plot : ggplot ggplot object to be built within the context. - show : bool (default: False) - Whether to show (``plt.show()``) the plot before the context exits. + show : bool + Whether to show the plot. """ # Default to retina unless user chooses otherwise diff --git a/plotnine/guides/guide.py b/plotnine/guides/guide.py index 9b01283f1..c616d7851 100644 --- a/plotnine/guides/guide.py +++ b/plotnine/guides/guide.py @@ -19,7 +19,7 @@ class guide(metaclass=Registry): Parameters ---------- - title : str, None + title : str, default=None Title of the guide. If `None`, title is not shown. Default is the name of the aesthetic or the name specified using [](`~plotnine.components.labels.lab`) @@ -53,7 +53,7 @@ class guide(metaclass=Registry): label_separation : float, default=None Separation between the label text and the colorbar. Value is in pixels. - direction : "horizontal", "vertical", default="auto" + direction : "horizontal" | "vertical", default="auto" Direction of the guide. The default is depends on [](`~plotnine.themes.themeable.legend_position`). default_unit : str, default="lines" diff --git a/plotnine/guides/guide_colorbar.py b/plotnine/guides/guide_colorbar.py index 2b9f5beeb..8359f727d 100644 --- a/plotnine/guides/guide_colorbar.py +++ b/plotnine/guides/guide_colorbar.py @@ -34,7 +34,7 @@ class guide_colorbar(guide): nbin : int, default=20 Number of bins for drawing a colorbar. A larger value yields a smoother colorbar - raster : bool, defaut=False + raster : bool, default=False Whether to render the colorbar as a raster object. ticks : bool, default=True Whether tick marks on colorbar should be visible. @@ -42,7 +42,7 @@ class guide_colorbar(guide): Whether to show the upper limit tick marks. draw_llim : bool, default=TRue Whether to show the lower limit tick marks. - direction : "horizontal", "vertical", default="horizontal" + direction : "horizontal" | "vertical", default="horizontal" Direction of the guide. kwargs : dict Parameters passed on to :class:`.guide` diff --git a/plotnine/guides/guide_legend.py b/plotnine/guides/guide_legend.py index d236e53b9..eb9a7ca8c 100644 --- a/plotnine/guides/guide_legend.py +++ b/plotnine/guides/guide_legend.py @@ -219,9 +219,10 @@ def _set_defaults(self, theme): # Take a peak into data['size'] to make sure the # legend dimensions are big enough """ - >>> gg = ggplot(diamonds, aes(x='cut', y='clarity')) - >>> gg = gg + stat_sum(aes(group='cut')) - >>> gg + scale_size(range=(3, 25)) + (ggplot(diamonds, aes(x="cut", y="clarity")) + + stat_sum(aes(group="cut")) + + scale_size(range=(3, 25) + ) Note the different height sizes for the entries """ diff --git a/plotnine/layer.py b/plotnine/layer.py index ceeb1ee6f..8612b281a 100644 --- a/plotnine/layer.py +++ b/plotnine/layer.py @@ -54,7 +54,7 @@ class layer: inherit_aes : bool If `True` inherit from the aesthetic mappings of the [](`~plotnine.ggplot`) object. - show_legend : bool or None + show_legend : bool | None Whether to make up and show a legend for the mappings of this layer. If `None` then an automatic/good choice is made @@ -375,7 +375,7 @@ def use_defaults( Parameters ---------- - data : dataframe, optional + data : dataframe Data aes_modifiers : dict Expression to evaluate and replace aesthetics in diff --git a/plotnine/mapping/aes.py b/plotnine/mapping/aes.py index 8653e9c58..a474e3a9d 100644 --- a/plotnine/mapping/aes.py +++ b/plotnine/mapping/aes.py @@ -175,7 +175,7 @@ class aes(Dict[str, Any]): ``` 2. `reorder` - This function changes the order of first variable - based on values of the second variable:: + based on values of the second variable: ```python df = pd.DataFrame({ @@ -325,12 +325,12 @@ def rename_aesthetics(obj: THasAesNames) -> THasAesNames: Parameters ---------- - obj : dict or list + obj : dict | list Object that contains aesthetics names Returns ------- - obj : dict or list + obj : dict | list Object that contains aesthetics names """ if isinstance(obj, dict): diff --git a/plotnine/positions/position.py b/plotnine/positions/position.py index 8a7969f37..744164fd7 100644 --- a/plotnine/positions/position.py +++ b/plotnine/positions/position.py @@ -112,10 +112,10 @@ def transform_position( ---------- data : dataframe Data to transform - trans_x : function + trans_x : callable Transforms x scale mappings Takes one argument, either a scalar or an array-type - trans_y : function + trans_y : callable Transforms y scale mappings Takes one argument, either a scalar or an array-type """ diff --git a/plotnine/positions/position_jitter.py b/plotnine/positions/position_jitter.py index 163e3c45a..a20b1c7b3 100644 --- a/plotnine/positions/position_jitter.py +++ b/plotnine/positions/position_jitter.py @@ -24,7 +24,7 @@ class position_jitter(position): height : float, default=None Proportion to jitter in vertical direction. If `None`, `0.4` of the resolution of the data. - random_state : int, ~numpy.random.RandomState, default=None + random_state : int | ~numpy.random.RandomState, default=None Seed or Random number generator to use. If `None`, then numpy global generator :class:`numpy.random` is used. """ diff --git a/plotnine/positions/position_jitterdodge.py b/plotnine/positions/position_jitterdodge.py index 6153b5e2c..7d20505d5 100644 --- a/plotnine/positions/position_jitterdodge.py +++ b/plotnine/positions/position_jitterdodge.py @@ -26,7 +26,7 @@ class position_jitterdodge(position): Proportion to jitter in vertical direction. dodge_width : float, default=0.75 Amount to dodge in horizontal direction. - random_state : int, ~numpy.random.RandomState, default=None + random_state : int | ~numpy.random.RandomState, default=None Seed or Random number generator to use. If `None`, then numpy global generator :class:`numpy.random` is used. """ diff --git a/plotnine/qplot.py b/plotnine/qplot.py index 3dc54794b..6ceea4a3e 100644 --- a/plotnine/qplot.py +++ b/plotnine/qplot.py @@ -68,7 +68,7 @@ def qplot( x-axis limits ylim : tuple y-axis limits - log : str in ``{'x', 'y', 'xy'}`` + log : "x" | "y" | "xy" Which (if any) variables to log transform. main : str Plot title diff --git a/plotnine/scales/limits.py b/plotnine/scales/limits.py index 12b51ff9c..1a8ebc5aa 100644 --- a/plotnine/scales/limits.py +++ b/plotnine/scales/limits.py @@ -216,7 +216,7 @@ def expand_limits(**kwargs): Parameters ---------- - kwargs : dict or dataframe + kwargs : dict | dataframe Data to use in expanding the limits. The keys should be aesthetic names e.g. *x*, *y*, *colour*, ... diff --git a/plotnine/scales/scale.py b/plotnine/scales/scale.py index 6998f0492..e2bc92e02 100644 --- a/plotnine/scales/scale.py +++ b/plotnine/scales/scale.py @@ -39,7 +39,7 @@ class scale(metaclass=Registry): Parameters ---------- - breaks : bool, list, callable, default=True + breaks : bool | list | callable, default=True List of major break points. Or a callable that takes a tuple of limits and returns a list of breaks. If `True`, automatically calculate the breaks. @@ -71,7 +71,7 @@ class scale(metaclass=Registry): Name used as the label of the scale. This is what shows up as the axis label or legend title. Suitable defaults are chosen depending on the type of scale. - labels : bool, list, callable, default=True + labels : bool | list | callable, default=True List of :py:class:`str`. Labels at the `breaks`. Alternatively, a callable that takes an array_like of break points as input and returns a list of strings. @@ -86,7 +86,7 @@ class scale(metaclass=Registry): palette : callable, default=None Function to map data points onto the scale. Most scales define their own palettes. - aesthetics : list, str, default=None + aesthetics : list | str, default=None list of :py:class:`str`. Aesthetics covered by the scale. These are defined by each scale and the user should probably not change them. Have fun. diff --git a/plotnine/scales/scale_color.py b/plotnine/scales/scale_color.py index 9a0340f88..7c88110c8 100644 --- a/plotnine/scales/scale_color.py +++ b/plotnine/scales/scale_color.py @@ -80,13 +80,13 @@ class scale_color_brewer(scale_discrete): Parameters ---------- - type : "seq", "div", "qual", default="seq" + type : "seq" | "div" | "qual", default="seq" Type of data. Sequential, diverging or qualitative - palette : int, str, default=1 + palette : int | str, default=1 If a string, will use that named palette. If a number, will index into the list of palettes of appropriate type. - direction: 1 or -1, default=1 + direction: 1 | -1, default=1 Sets the order of colors in the scale. If 1, colors are as output by [](`~mizani.palettes.brewer_pal`). If -1, the order of colors is reversed. @@ -219,7 +219,7 @@ class scale_color_desaturate(scale_continuous): Parameters ---------- - color : str, default="red" + color : str, default="red" Color to desaturate prop : float, default=0 Saturation channel of color will be multiplied by @@ -381,9 +381,9 @@ class scale_color_distiller(scale_color_gradientn): Parameters ---------- - type : "seq", "div", default="seq" + type : "seq" | "div", default="seq" Type of data. Sequential, diverging or qualitative - palette : int, str, default=1 + palette : int | str, default=1 If a string, will use that named palette. If a number, will index into the list of palettes of appropriate type. Default is 1 @@ -391,7 +391,7 @@ class scale_color_distiller(scale_color_gradientn): list of points in the range [0, 1] at which to place each color. Must be the same size as `colors`. Default to evenly space the colors - direction: -1, 1, default=-1 + direction: -1 | 1, default=-1 Sets the order of colors in the scale. If 1 colors are as output by [](`~mizani.palettes.brewer_pal`). If -1, the order of colors is reversed. diff --git a/plotnine/scales/scale_continuous.py b/plotnine/scales/scale_continuous.py index f55064357..09ed5ac69 100644 --- a/plotnine/scales/scale_continuous.py +++ b/plotnine/scales/scale_continuous.py @@ -44,14 +44,14 @@ class scale_continuous(scale): Parameters ---------- {superclass_parameters} - trans : str | function + trans : str | callable Name of a trans function or a trans function. See :mod:`mizani.transforms` for possible options. oob : callable, default=mizani.bounds.censor Function to deal with out of bounds (limits) data points. Default is to turn them into `np.nan`, which then get dropped. - minor_breaks : list, int, callable, default=None + minor_breaks : list | int | callable, default=None If a list-like, it is the minor breaks points. If an integer, it is the number of minor breaks between any set of major breaks. @@ -445,7 +445,7 @@ def get_labels( Parameters ---------- - breaks: None or array-like + breaks: None | array-like If None, use self.breaks. """ if breaks is None: diff --git a/plotnine/scales/scale_identity.py b/plotnine/scales/scale_identity.py index 7019fcc71..182187fe1 100644 --- a/plotnine/scales/scale_identity.py +++ b/plotnine/scales/scale_identity.py @@ -46,7 +46,7 @@ class scale_color_identity(MapTrainMixin, scale_discrete): Parameters ---------- {superclass_parameters} - guide : None, 'legend', default=None + guide : None | "legend", default=None Whether to include a legend. """ @@ -74,7 +74,7 @@ class scale_shape_identity(MapTrainMixin, scale_discrete): Parameters ---------- {superclass_parameters} - guide : None, 'legend', default=None + guide : None | "legend", default=None Whether to include a legend. """ @@ -89,7 +89,7 @@ class scale_linetype_identity(MapTrainMixin, scale_discrete): Parameters ---------- {superclass_parameters} - guide : None, 'legend', default=None + guide : None | "legend", default=None Whether to include a legend. """ @@ -104,7 +104,7 @@ class scale_alpha_identity(MapTrainMixin, scale_continuous): Parameters ---------- {superclass_parameters} - guide : None, 'legend', default=None + guide : None | "legend", default=None Whether to include a legend. """ @@ -119,7 +119,7 @@ class scale_size_identity(MapTrainMixin, scale_continuous): Parameters ---------- {superclass_parameters} - guide : None, 'legend', default=None + guide : None | "legend", default=None Whether to include a legend. """ diff --git a/plotnine/stats/binning.py b/plotnine/stats/binning.py index af92348dd..cd138c2a4 100644 --- a/plotnine/stats/binning.py +++ b/plotnine/stats/binning.py @@ -141,7 +141,7 @@ def assign_bins(x, breaks, weight=None, pad=False, closed="right"): table. If `None`, then each value in `x` has a weight of 1. pad : bool If `True`, add empty bins at either end of `x`. - closed : str in ``['right', 'left']`` + closed : "right" | "left" Whether the right or left edges of the bins are part of the bin. diff --git a/plotnine/stats/smoothers.py b/plotnine/stats/smoothers.py index 877a1d58b..0f803b78b 100644 --- a/plotnine/stats/smoothers.py +++ b/plotnine/stats/smoothers.py @@ -477,24 +477,24 @@ def wls_prediction_std( Parameters ---------- - res : regression result instance + res : regression-result results of WLS or OLS regression required attributes see notes - exog : array_like (optional) + exog : array_like exogenous variables for points to predict - weights : scalar or array_like (optional) + weights : scalar | array_like weights as defined for WLS (inverse of variance of observation) - alpha : float (default: alpha = 0.05) + alpha : float confidence level for two-sided hypothesis interval : str Type of interval to compute. One of "confidence" or "prediction" Returns ------- - predstd : array_like, 1d - standard error of prediction - same length as rows of exog + predstd : array_like + Standard error of prediction. It must be the same length as rows + of exog. interval_l, interval_u : array_like - lower und upper confidence bounds + Lower und upper confidence bounds Notes ----- diff --git a/plotnine/stats/stat.py b/plotnine/stats/stat.py index aabfa4060..22a9c7e47 100644 --- a/plotnine/stats/stat.py +++ b/plotnine/stats/stat.py @@ -319,10 +319,11 @@ def compute_panel( scales : dataclass x (``scales.x``) and y (``scales.y``) scale objects. The most likely reason to use scale information is - to find out the physical size of a scale. e.g:: - - range_x = scales.x.dimension() + to find out the physical size of a scale. e.g. + ```python + range_x = scales.x.dimension() + ``` params : dict The parameters for the stat. It includes default values if user did not set a particular parameter. @@ -371,10 +372,11 @@ def compute_group( scales : types.SimpleNamespace x (``scales.x``) and y (``scales.y``) scale objects. The most likely reason to use scale information is - to find out the physical size of a scale. e.g:: - - range_x = scales.x.dimension() + to find out the physical size of a scale. e.g. + ```python + range_x = scales.x.dimension() + ``` params : dict Parameters """ diff --git a/plotnine/stats/stat_bin.py b/plotnine/stats/stat_bin.py index bfc8acf4f..1e7cbdf07 100644 --- a/plotnine/stats/stat_bin.py +++ b/plotnine/stats/stat_bin.py @@ -24,33 +24,33 @@ class stat_bin(stat): Parameters ---------- {common_parameters} - binwidth : float, optional (default: None) + binwidth : float, default=None The width of the bins. The default is to use bins bins that cover the range of the data. You should always override this value, exploring multiple widths to find the best to illustrate the stories in your data. - bins : int, optional (default: None) + bins : int, default=None Number of bins. Overridden by binwidth. If `None`{.py}, a number is computed using the freedman-diaconis method. - breaks : array-like, optional (default: None) + breaks : array-like, default=None Bin boundaries. This supercedes the `binwidth`, `bins`, `center` and `boundary`. - center : float, optional (default: None) + center : float, default=None The center of one of the bins. Note that if center is above or below the range of the data, things will be shifted by an appropriate number of widths. To center on integers, for example, use `width=1`{.py} and :py:`center=0`, even if 0 i s outside the range of the data. At most one of center and boundary may be specified. - boundary : float, optional (default: None) + boundary : float, default=None A boundary between two bins. As with center, things are shifted when boundary is outside the range of the data. For example, to center on integers, use `width=1`{.py} and `boundary=0.5`{.py}, even if 1 is outside the range of the data. At most one of center and boundary may be specified. - closed : str, optional (default: right) - Which edge of the bins is included, *left* or *right*. - pad : bool, optional (default: False) + closed : "left" | "right", default="right" + Which edge of the bins is included. + pad : bool, default=False If `True`{.py}, adds empty bins at either side of x. This ensures that frequency polygons touch 0. """ diff --git a/plotnine/stats/stat_bin_2d.py b/plotnine/stats/stat_bin_2d.py index 7174f7157..5527b097c 100644 --- a/plotnine/stats/stat_bin_2d.py +++ b/plotnine/stats/stat_bin_2d.py @@ -21,19 +21,19 @@ class stat_bin_2d(stat): Parameters ---------- {common_parameters} - bins : int, optional (default: 30) + bins : int, default=30 Number of bins. Overridden by binwidth. - breaks : array-like(s), optional (default: None) + breaks : array-like(s), default=None Bin boundaries. This supercedes the `binwidth`, `bins`, `center` and `boundary`. It can be an array_like or a list of two array_likes to provide distinct breaks for the `x` and `y` axes. - binwidth : float, optional (default: None) + binwidth : float, default=None The width of the bins. The default is to use bins bins that cover the range of the data. You should always override this value, exploring multiple widths to find the best to illustrate the stories in your data. - drop : bool, optional (default: False) + drop : bool, default=False If `True`{.py}, removes all cells with zero counts. """ diff --git a/plotnine/stats/stat_bindot.py b/plotnine/stats/stat_bindot.py index 2c572eb63..647c86e0a 100644 --- a/plotnine/stats/stat_bindot.py +++ b/plotnine/stats/stat_bindot.py @@ -37,14 +37,14 @@ class stat_bindot(stat): binwidth. This supercedes the `bins`. origin : float, default=None When `method='histodot'`{.py}, origin of the first bin. - width : float, optional (default: 0.9) + width : float, default=0.9 When `binaxis='y'`{.py}, the spacing of the dotstacks for dodging. - binaxis : "x", "y", default="x" + binaxis : "x" | "y", default="x" Axis to bin along. - method : "dotdensity", "histodot", default="dotdensity" + method : "dotdensity" | "histodot", default="dotdensity" Whether to do dot-density binning or fixed widths binning. - binpositions : "all", "bygroup", default="bygroup" + binpositions : "all" | "bygroup", default="bygroup" Position of the bins when `method="dotdensity"`{.py}. The value - `bygroup` - positions of the bins for each group are determined separately. diff --git a/plotnine/stats/stat_boxplot.py b/plotnine/stats/stat_boxplot.py index b885705b5..ce474fe9e 100644 --- a/plotnine/stats/stat_boxplot.py +++ b/plotnine/stats/stat_boxplot.py @@ -164,9 +164,9 @@ def weighted_boxplot_stats(x, weights=None, whis=1.5): ---------- x : array_like Data - weights : array_like, optional + weights : array_like Weights associated with the data. - whis : float, optional (default: 1.5) + whis : float Position of the whiskers beyond the interquartile range. The data beyond the whisker are considered outliers. diff --git a/plotnine/stats/stat_density.py b/plotnine/stats/stat_density.py index e9aa92b7c..0f7e9b429 100644 --- a/plotnine/stats/stat_density.py +++ b/plotnine/stats/stat_density.py @@ -57,7 +57,7 @@ class stat_density(stat): of two. gridsize : int, default=None If gridsize is `None`{.py}, `max(len(x), 50)`{.py} is used. - bw : str, float, default="nrd0" + bw : str | float, default="nrd0" The bandwidth to use, If a float is given, it is the bandwidth. The options are: diff --git a/plotnine/stats/stat_density_2d.py b/plotnine/stats/stat_density_2d.py index 9f3f84531..69f803d3c 100644 --- a/plotnine/stats/stat_density_2d.py +++ b/plotnine/stats/stat_density_2d.py @@ -22,10 +22,10 @@ class stat_density_2d(stat): Number of equally spaced points at which the density is to be estimated. For efficient computation, it should be a power of two. - levels : int, array_like, default=5 + levels : int | array_like, default=5 Contour levels. If an integer, it specifies the maximum number of levels, if array_like it is the levels themselves. - package : "statsmodels", "scipy", "sklearn", default="statsmodels" + package : "statsmodels" | "scipy" | "sklearn", default="statsmodels" Package whose kernel density estimation to use. kde_params : dict Keyword arguments to pass on to the kde class. diff --git a/plotnine/stats/stat_ellipse.py b/plotnine/stats/stat_ellipse.py index aea5c4ed0..71b9bdeae 100644 --- a/plotnine/stats/stat_ellipse.py +++ b/plotnine/stats/stat_ellipse.py @@ -26,17 +26,16 @@ class stat_ellipse(stat): Parameters ---------- {common_parameters} - type : "t", "norm", "euclid", default="t" + type : "t" | "norm" | "euclid", default="t" The type of ellipse. - - - `t` - assumes a multivariate t-distribution, and - - `norm` - assumes a multivariate normal distribution. - - `euclid` - draws a circle with the radius equal to + `t` assumes a multivariate t-distribution. + `norm` assumes a multivariate normal distribution. + `euclid` draws a circle with the radius equal to `level`, representing the euclidean distance from the center. level : float, default=0.95 The confidence level at which to draw the ellipse. - segments : int, ptional (default=51 + segments : int, default=51 Number of segments to be used in drawing the ellipse. """ @@ -131,8 +130,8 @@ def cov_trob( if the case i actually occurred `wt[i]` times. cor : bool Flag to choose between returning the correlation - (``cor=True``) or covariance (``cor=False``) matrix. - center : array or bool + (`cor=True`) or covariance (`cor=False`) matrix. + center : array | bool A logical value or a numeric vector providing the location about which the covariance is to be taken. If `center=False`, no centering is done; if diff --git a/plotnine/stats/stat_function.py b/plotnine/stats/stat_function.py index d0d9d649e..eb403fa99 100644 --- a/plotnine/stats/stat_function.py +++ b/plotnine/stats/stat_function.py @@ -27,7 +27,7 @@ class stat_function(stat): Parameters ---------- {common_parameters} - fun : function + fun : callable Function to evaluate. n : int, default=101 Number of points at which to evaluate the function. @@ -35,7 +35,7 @@ class stat_function(stat): `x` limits for the range. The default depends on the `x` aesthetic. There is not an `x` aesthetic then the `xlim` must be provided. - args : tuple, dict, default=None + args : tuple | dict, default=None Arguments to pass to `fun`. """ @@ -45,8 +45,8 @@ class stat_function(stat): **Options for computed aesthetics** ```python - 'x' # x points at which the function is evaluated - 'fx' # points evaluated at each x + "x" # x points at which the function is evaluated + "fx" # points evaluated at each x ``` """ diff --git a/plotnine/stats/stat_pointdensity.py b/plotnine/stats/stat_pointdensity.py index 1da7c48ca..0726c9d9a 100644 --- a/plotnine/stats/stat_pointdensity.py +++ b/plotnine/stats/stat_pointdensity.py @@ -17,7 +17,7 @@ class stat_pointdensity(stat): Parameters ---------- {common_parameters} - package : "statsmodels", "scipy", "sklearn", default="statsmodels" + package : "statsmodels" | "scipy" | "sklearn", default="statsmodels" Package whose kernel density estimation to use. kde_params : dict, default=None Keyword arguments to pass on to the kde class. diff --git a/plotnine/stats/stat_sina.py b/plotnine/stats/stat_sina.py index ad6275a2c..6aa62178e 100644 --- a/plotnine/stats/stat_sina.py +++ b/plotnine/stats/stat_sina.py @@ -28,7 +28,7 @@ class stat_sina(stat): illustrate the stories in your data. bins : int, default=50 Number of bins. Overridden by binwidth. - method : "density", "counts", default="density" + method : "density" | "counts", default="density" Choose the method to spread the samples within the same bin along the x-axis. Available methods: "density", "counts" (can be abbreviated, e.g. "d"). See Details. @@ -38,7 +38,7 @@ class stat_sina(stat): adjust : float, default=1 Adjusts the bandwidth of the density kernel when `method="density"`. see [](`~plotnine.stats.stat_density`). - bw : str, float, default="nrd0" + bw : str | float, default="nrd0" The bandwidth to use, If a float is given, it is the bandwidth. The `str`{.py} choices are: `"nrd0", "normal_reference", "scott", "silverman"`{.py} @@ -49,10 +49,10 @@ class stat_sina(stat): 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} - random_state : int, ~numpy.random.RandomState, default=None + random_state : int | ~numpy.random.RandomState, default=None Seed or Random number generator to use. If `None`, then numpy global generator :class:`numpy.random` is used. - scale : "area", "count", "width", default="area" + scale : "area" | "count" | "width", default="area" How to scale the sina groups. - `area` - Scale by the largest density/bin among the different sinas diff --git a/plotnine/stats/stat_smooth.py b/plotnine/stats/stat_smooth.py index eaeae198b..249082acb 100644 --- a/plotnine/stats/stat_smooth.py +++ b/plotnine/stats/stat_smooth.py @@ -19,8 +19,8 @@ class stat_smooth(stat): Parameters ---------- {common_parameters} - method : str, callable, default="auto" - The available methods are:: + method : str | callable, default="auto" + The available methods are: ```python "auto" # Use loess if (n<1000), glm otherwise "lm", "ols" # Linear Model diff --git a/plotnine/stats/stat_summary.py b/plotnine/stats/stat_summary.py index 43fbd1f36..27ecc7ae7 100644 --- a/plotnine/stats/stat_summary.py +++ b/plotnine/stats/stat_summary.py @@ -45,11 +45,11 @@ def mean_cl_boot( ---------- series : pandas.Series Values - n_samples : int (default: 1000) + n_samples : int, default=1000 Number of sample to draw. confidence_interval : float Confidence interval in the range (0, 1). - random_state : int or ~numpy.random.RandomState, optional + random_state : int | ~numpy.random.RandomState, default=None Seed or Random number generator to use. If `None`, then numpy global generator :class:`numpy.random` is used. """ @@ -190,8 +190,8 @@ class stat_summary(stat): Parameters ---------- {common_parameters} - fun_data : str or function, default="mean_cl_boot" - One of: + fun_data : str | callable, default="mean_cl_boot" + If string, it should be one of: ```python # Bootstrapped mean, confidence interval @@ -224,19 +224,19 @@ class stat_summary(stat): or any function that takes a array and returns a dataframe with three columns named `y`, `ymin` and `ymax`. - fun_y : function, optional (default: None) + fun_y : callable, default=None Any function that takes a array-like and returns a value - fun_ymin : function (default:None) + fun_ymin : callable, default=None Any function that takes an array-like and returns a value - fun_ymax : function, optional (default: None) + fun_ymax : callable, default=None Any function that takes an array-like and returns a value - fun_args : dict, optional (default: None) + fun_args : dict, default=None Arguments to any of the functions. Provided the names of the arguments of the different functions are in not conflict, the arguments will be assigned to the right functions. If there is a conflict, create a wrapper function that resolves the ambiguity in the argument names. - random_state : int or ~numpy.random.RandomState, optional + random_state : int | ~numpy.random.RandomState, default=None Seed or Random number generator to use. If `None`, then numpy global generator :class:`numpy.random` is used. diff --git a/plotnine/stats/stat_summary_bin.py b/plotnine/stats/stat_summary_bin.py index 4e78bb4f9..b07b5b68d 100644 --- a/plotnine/stats/stat_summary_bin.py +++ b/plotnine/stats/stat_summary_bin.py @@ -20,39 +20,38 @@ class stat_summary_bin(stat): Parameters ---------- {common_parameters} - binwidth : float or tuple, optional (default: None) + binwidth : float | tuple, default=None The width of the bins. The default is to use bins bins that cover the range of the data. You should always override this value, exploring multiple widths to find the best to illustrate the stories in your data. - bins : int or tuple, optional (default: 30) + bins : int | tuple, default=30 Number of bins. Overridden by binwidth. - breaks : array-like(s), optional (default: None) + breaks : array-likes, default=None Bin boundaries. This supercedes the `binwidth`, `bins` and `boundary` arguments. - boundary : float or tuple, optional (default: None) + boundary : float | tuple, default=None A boundary between two bins. As with center, things are shifted when boundary is outside the range of the data. For example, to center on integers, use `width=1`{.py} and `boundary=0.5`{.py}, even if 1 is outside the range of the data. At most one of center and boundary may be specified. - fun_data : str or function, optional - One of - `['mean_cl_boot', 'mean_cl_normal', 'mean_sdl', 'median_hilow', - 'mean_se']`{.py} or any function that takes a array and returns a + fun_data : str | callable, default="mean_se" + If a string, should be one of `mean_cl_boot`, `mean_cl_normal`, + `mean_sdl`, `median_hilow`, `mean_se`. + If a function, it should that takes an array and return a dataframe with three rows indexed as `y`, `ymin` and `ymax`. - Defaults to `'mean_se'`{.py}. - fun_y : function, optional (default: None) - Any function that takes an array-like and returns a single value - fun_ymax : function, optional (default: None) - Any function that takes an array-like and returns a single value - fun_args : dict, optional (default: None) + fun_y : callable, default=None + A function that takes an array-like and returns a single value + fun_ymax : callable, default=None + A function that takes an array-like and returns a single value + fun_args : dict, default=None Arguments to any of the functions. Provided the names of the arguments of the different functions are in not conflict, the arguments will be assigned to the right functions. If there is a conflict, create a wrapper function that resolves the ambiguity in the argument names. - random_state : int or ~numpy.random.RandomState, optional + random_state : int | ~numpy.random.RandomState, default=None Seed or Random number generator to use. If `None`, then numpy global generator :class:`numpy.random` is used. diff --git a/plotnine/stats/stat_ydensity.py b/plotnine/stats/stat_ydensity.py index 907a19f65..15bce9a7d 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, optional (default: 'gaussian') + kernel : str, default='gaussian' Kernel used for density estimation. One of: ```python @@ -32,26 +32,27 @@ class stat_ydensity(stat): "triweight" "uniform" ``` - adjust : float, optional (default: 1) + adjust : float, default=1 An adjustment factor for the `bw`. Bandwidth becomes `bw * adjust`{.py}. Adjustment of the bandwidth. - trim : bool, optional (default: False) + trim : bool, default=False This parameter only matters if you are displaying multiple densities in one plot. If `False`{.py}, the default, each density is computed on the full range of the data. If `True`{.py}, each density is computed over the range of that group; this typically means the estimated x values will not line-up, and hence you won't be able to stack density values. - n : int, optional(default: 1024) + n : int, default=1024 Number of equally spaced points at which the density is to be estimated. For efficient computation, it should be a power of two. - bw : str or float, optional (default: 'nrd0') + bw : str | float, default="nrd0" The bandwidth to use, If a float is given, it is the bandwidth. The `str` choices are: ```python + "nrd0" "normal_reference" "scott" "silverman" @@ -59,21 +60,12 @@ class stat_ydensity(stat): `nrd0` is a port of `stats::bw.nrd0` in R; it is eqiuvalent to `silverman` when there is more than 1 value in a group. - scale : (default: area) + scale : "area" | "count" | "width", default="area" How to scale the violins. The options are: - - ```python - # all violins have the same area, before - # trimming the tails. - "area" - - # areas are scaled proportionally to the number - # of observations. - "count" - - # all violins have the same maximum width. - "width" - ``` + If `area` all violins have the same area, before trimming the tails. + If `count` the areas are scaled proportionally to the number of + observations. + If `width` all violins have the same maximum width. See Also -------- diff --git a/plotnine/themes/elements.py b/plotnine/themes/elements.py index 5d96a5277..0d9adb46d 100644 --- a/plotnine/themes/elements.py +++ b/plotnine/themes/elements.py @@ -148,18 +148,18 @@ class element_text(element_base): family : str Font family. See :meth:`matplotlib.text.Text.set_family` for supported values. - style : str in ``['normal', 'italic', 'oblique']`` + style : "normal" | "italic" | "oblique"` Font style color : str | tuple Text color weight : str - Should be one of *normal*, *bold*, *heavy*, *light*, - *ultrabold* or *ultralight*. + Should be one of `normal`, `bold`, `heavy`, `light`, + `ultrabold` or `ultralight`. size : float text size - ha : str in ``['center', 'left', 'right']`` + ha : "center" | "left" | "right" Horizontal Alignment. - va : str in ``['center' , 'top', 'bottom', 'baseline']`` + va : "center" | "top" | "bottom" | "baseline" Vertical alignment. rotation : float Rotation angle in the range [0, 360] @@ -167,13 +167,13 @@ class element_text(element_base): Line spacing backgroundcolor : str | tuple Background color - margin : dict - Margin around the text. The keys are one of - ``['t', 'b', 'l', 'r']`` and `units`. The units are - one of ``['pt', 'lines', 'in']``. The *units* default - to `pt` and the other keys to `0`. Not all text - themeables support margin parameters and other than the - `units`, only some of the other keys may apply. + margin : dict, default={"t": 0, "b": 0, "l": 0, "r": 0, "units": "pt"} + Margin around the text. The keys are + `t`, `b`, `l`, `r` and `units`. + The `tblr` keys are floats. + The `units` is one of `pt`, `lines` or `in`. + Not all text themeables support margin parameters and other + than the `units`, only some of the other keys may apply. kwargs : dict Parameters recognised by :class:`matplotlib.text.Text` diff --git a/plotnine/themes/seaborn_rcmod.py b/plotnine/themes/seaborn_rcmod.py index 2932f2077..22d1bcbc4 100644 --- a/plotnine/themes/seaborn_rcmod.py +++ b/plotnine/themes/seaborn_rcmod.py @@ -113,7 +113,7 @@ def set_theme( Color palette, see :func:`color_palette` font : string Font family, see matplotlib font manager. - font_scale : float, optional + font_scale : float Separate scaling factor to independently scale the size of the font elements. color_codes : bool @@ -151,9 +151,9 @@ def axes_style(style=None, rc=None): Parameters ---------- - style : dict, None, or one of {darkgrid, whitegrid, dark, white, ticks} + style : "darkgrid" | "whitegrid" | "dark" | "white" | "ticks" | dict | None A dictionary of parameters or the name of a preconfigured set. - rc : dict, optional + rc : dict Parameter mappings to override the values in the preset seaborn style dictionaries. This only updates parameters that are considered part of the style definition. @@ -312,9 +312,9 @@ def set_style(style=None, rc=None): Parameters ---------- - style : dict, None, or one of {darkgrid, whitegrid, dark, white, ticks} + style : "darkgrid" | "whitegrid" | "dark" | "white" | "ticks" | dict | None A dictionary of parameters or the name of a preconfigured set. - rc : dict, optional + rc : dict Parameter mappings to override the values in the preset seaborn style dictionaries. This only updates parameters that are considered part of the style definition. diff --git a/plotnine/themes/theme.py b/plotnine/themes/theme.py index 3c954d893..a7d6f89b1 100644 --- a/plotnine/themes/theme.py +++ b/plotnine/themes/theme.py @@ -49,25 +49,28 @@ class theme: complete : bool Themes that are complete will override any existing themes. themes that are not complete (ie. partial) will add to or - override specific elements of the current theme. e.g:: + override specific elements of the current theme. e.g: - theme_gray() + theme_xkcd() + ```python + theme_gray() + theme_xkcd() + ``` will be completely determined by [](`~plotnine.themes.theme_xkcd`), but: - theme_gray() + theme(axis_text_x=element_text(angle=45)) + ```python + theme_gray() + theme(axis_text_x=element_text(angle=45)) + ``` will only modify the x-axis text. - kwargs: dict kwargs are :ref:`themeables `. The themeables are elements that are subclasses of `themeable`. Many themeables are defined using theme elements i.e - - [](`~plotnine.themes.element_line`) - - [](`~plotnine.themes.element_rect`) - - [](`~plotnine.themes.element_text`) + - [](`~plotnine.themes.element_line`) + - [](`~plotnine.themes.element_rect`) + - [](`~plotnine.themes.element_text`) These simply bind together all the aspects of a themeable that can be themed. See [](`~plotnine.themes.themeable.themeable`). @@ -341,10 +344,12 @@ def __radd__(self, other: theme | Ggplot) -> theme | Ggplot: """ Add theme to ggplot object or to another theme - This will be called in one of two ways:: + This will be called in one of two ways: - ggplot() + theme() - theme1() + theme2() + ```python + ggplot() + theme() + theme1() + theme2() + ``` In both cases, `self` is the [](`~plotnine.themes.theme`) on the right hand side. diff --git a/plotnine/themes/theme_matplotlib.py b/plotnine/themes/theme_matplotlib.py index e11d6ea54..5f267fc11 100644 --- a/plotnine/themes/theme_matplotlib.py +++ b/plotnine/themes/theme_matplotlib.py @@ -12,7 +12,7 @@ class theme_matplotlib(theme): Parameters ---------- - rc : dict + rc : dict rcParams which should be applied on top of mathplotlib default. fname : str Filename to a matplotlibrc file diff --git a/plotnine/themes/theme_void.py b/plotnine/themes/theme_void.py index 5572070a2..8115c1cd6 100644 --- a/plotnine/themes/theme_void.py +++ b/plotnine/themes/theme_void.py @@ -10,10 +10,10 @@ class theme_void(theme): Parameters ---------- - base_size : int, optional + base_size : int Base font size. All text sizes are a scaled versions of - the base font size. Default is 11. - base_family : int, optional + the base font size. + base_family : str Base font family. """ diff --git a/plotnine/themes/theme_xkcd.py b/plotnine/themes/theme_xkcd.py index 1b1213b8c..6e214ce89 100644 --- a/plotnine/themes/theme_xkcd.py +++ b/plotnine/themes/theme_xkcd.py @@ -22,7 +22,7 @@ class theme_xkcd(theme_gray): The factor by which the length is randomly scaled. Default is 2. stroke_size : float Size of the stroke to apply to the lines and text paths. - stroke_color : str, tuple + stroke_color : str | tuple Color of the strokes. Use `"none"` for no color. """ diff --git a/plotnine/themes/themeable.py b/plotnine/themes/themeable.py index bddd241be..b7a78a4cd 100644 --- a/plotnine/themes/themeable.py +++ b/plotnine/themes/themeable.py @@ -61,17 +61,17 @@ class themeable(metaclass=RegistryHierarchyMeta): You would have this implementation: - :: - class axis_title_x(themeable): - ... + ```python + class axis_title_x(themeable): + ... - class axis_title_y(themeable): - ... - - class axis_title(axis_title_x, axis_title_y): - ... + class axis_title_y(themeable): + ... + class axis_title(axis_title_x, axis_title_y): + ... + ``` If the superclasses fully implement the subclass, the body of the subclass should be "pass". Python(__mro__) will do the right thing. @@ -1696,10 +1696,10 @@ class axis_ticks_direction_x(themeable): Parameters ---------- - theme_element : "in", "out", "inout" - - `in` - ticks inside the panel - - `out` - ticks outside the panel - - `inout` - ticks inside and outside the panel + theme_element : "in" | "out" | "inout" + `in` for ticks inside the panel. + `out` for ticks outside the panel. + `inout` for ticks inside and outside the panel. """ def apply_ax(self, ax: Axes): @@ -1715,10 +1715,10 @@ class axis_ticks_direction_y(themeable): Parameters ---------- - theme_element : "in", "out", "inout" - - `in` - ticks inside the panel - - `out` - ticks outside the panel - - `inout` - ticks inside and outside the panel + theme_element : "in" | "out" | "inout" + `in` for ticks inside the panel. + `out` for ticks outside the panel. + `inout` for ticks inside and outside the panel. """ def apply_ax(self, ax: Axes): @@ -1734,10 +1734,10 @@ class axis_ticks_direction(axis_ticks_direction_x, axis_ticks_direction_y): Parameters ---------- - theme_element : "in", "out", "inout" - - `in` - ticks inside the panel - - `out` - ticks outside the panel - - `inout` - ticks inside and outside the panel + theme_element : "in" | "out" | "inout" + `in` for ticks inside the panel. + `out` for ticks outside the panel. + `inout` for ticks inside and outside the panel. """ @@ -1919,7 +1919,7 @@ class legend_box(themeable): Parameters ---------- - theme_element : "vertical", "horizontal" + theme_element : "vertical" | "horizontal" Whether to stack up the legends vertically or horizontally. """ @@ -1942,9 +1942,8 @@ class legend_box_just(themeable): Parameters ---------- - theme_element : str - One of `["left", "right", "center", "top", "bottom"]`{.py} - depending the value of :class:`legend_box`. + theme_element : "left", "right", "center", "top", "bottom", default=None + If `None`, the value that will apply depends on :class:`legend_box`. """ @@ -1954,7 +1953,7 @@ class legend_direction(themeable): Parameters ---------- - theme_element : str in `["vertical", "horizontal"]`{.py} + theme_element : "vertical" | "horizontal" Vertically or horizontally """ @@ -2031,12 +2030,10 @@ class legend_position(themeable): Parameters ---------- - theme_element : str or tuple - If a string it should be one of - `["right", "left", "top", "bottom", "none"]`{.py} - If a tuple, it should be two floats each - in the approximate range [0, 1]. The tuple specifies the - location of the legend in screen coordinates. + theme_element : "right" | "left" | "top" | "bottom" | "none" | tuple + If `none`, no legend. + If a tuple, 2-floats in the range `[0, 1]` for the location + in screen coordinates. """ @@ -2046,9 +2043,8 @@ class legend_title_align(themeable): Parameters ---------- - theme_element : str or tuple - If a string it should be one of - `["right", "left", "center", "top", "bottom"]`{.py} + theme_element : "right" | "left" | "center" | "top" | "bottom" | "auto" + If `auto`, depends on the position of the legend. """ diff --git a/plotnine/utils.py b/plotnine/utils.py index 90dee0577..158663b0b 100644 --- a/plotnine/utils.py +++ b/plotnine/utils.py @@ -423,7 +423,7 @@ def jitter(x, factor=1, amount=None, random_state=None): If `None` then `amount = factor * d/5`, where d is about the smallest difference between `x` values and `z` is the range of the `x` values. - random_state : int or ~numpy.random.RandomState, optional + random_state : int | ~numpy.random.RandomState, default=None Seed or Random number generator to use. If `None`, then numpy global generator :class:`numpy.random` is used. @@ -610,7 +610,7 @@ def groupby_apply( ---------- cols : str | list of str columns to groupby - func : function + func : callable function to call on the grouped data *args : tuple positional parameters to pass to func @@ -652,7 +652,7 @@ def pivot_apply(df, column, index, func, *args, **kwargs): index : str Column that will be grouped on (and whose unique values will make up the index of the returned dataframe) - func : function + func : callable Function to apply to each column group. It *should* return a single value. *args : tuple @@ -1185,7 +1185,7 @@ def continuous(arr): Parameters ---------- - arr : numpy.array or pandas.series + arr : numpy.array | pandas.series Must have a dtype Returns @@ -1229,15 +1229,15 @@ def log(x, base=None): Parameters ---------- - x : float or array_like + x : float | array_like Input values - base : int or float (Default: None) + base : int | float, default=None Base of the log. If `None`, the natural logarithm is computed (`base=np.e`). Returns ------- - out : float or ndarray + out : float | ndarray Calculated result """ if base == 10: diff --git a/plotnine/watermark.py b/plotnine/watermark.py index 733761cbc..97271e4f2 100644 --- a/plotnine/watermark.py +++ b/plotnine/watermark.py @@ -19,7 +19,7 @@ class watermark: Parameters ---------- - filename : str, pathlib.Path + filename : str | pathlib.Path Image file xo : int x position offset in pixels. diff --git a/tests/test_doctools.py b/tests/test_doctools.py index c0be723e1..606646a39 100644 --- a/tests/test_doctools.py +++ b/tests/test_doctools.py @@ -12,13 +12,13 @@ class scale_expand(scale): Parameters ---------- - base_param_1 : int or float + base_param_1 : int | float Base Param 1 Description base_param_2 : str Base Param 2 Description base_param_3 : dict Base Param 3 Description - specific_parameter : str, optional + specific_parameter : str Base Specific Parameter Description """ @@ -29,7 +29,7 @@ class mixin: Parameters ---------- - mixin_param_1 : int or float + mixin_param_1 : int | float Mixin Param 1 Description mixin_param_2 : str Mixin Param 2 Description @@ -44,7 +44,7 @@ class scale_expand_earth(mixin, scale_expand): Parameters ---------- {superclass_parameters} - derived_param_1 : int or float + derived_param_1 : int | float Derived Param 1 Description derived_param_2: float Derived Param 2 Description @@ -64,7 +64,7 @@ def test_document_scale(): assert doc.count("mixin_param_2") == 1 # overridden parameter - assert "specific_parameter : str, optional" not in doc + assert "specific_parameter : str" in doc assert "Base Specific Parameter Description" not in doc assert doc.count("specific_parameter : str") == 1 assert doc.count("Derived Specific Parameter Description") == 1 @@ -92,8 +92,9 @@ class geom_abc(geom): def test_document_geom(): doc = geom_abc.__doc__ - assert "~plotnine.stats.stat_bin" in doc - assert "position_stack" in doc + # assert "~plotnine.stats.stat_bin" in doc + assert 'stat, default="bin"' in doc + assert 'position, default="position_stack"' in doc @document @@ -115,4 +116,5 @@ class stat_abc(stat): def test_document_stat(): doc = stat_abc.__doc__ assert "geom_abc" in doc - assert "~plotnine.positions.position_stack" in doc + # assert "~plotnine.positions.position_stack" in doc + assert 'position, default="stack"' in doc