plotnine 0.15.0a2__py3-none-any.whl → 0.15.0a3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. plotnine/_mpl/layout_manager/_layout_tree.py +16 -6
  2. plotnine/_utils/__init__.py +4 -2
  3. plotnine/geoms/annotation_logticks.py +5 -8
  4. plotnine/geoms/annotation_stripes.py +4 -6
  5. plotnine/geoms/geom.py +20 -8
  6. plotnine/geoms/geom_abline.py +3 -2
  7. plotnine/geoms/geom_blank.py +0 -3
  8. plotnine/geoms/geom_boxplot.py +4 -4
  9. plotnine/geoms/geom_crossbar.py +3 -3
  10. plotnine/geoms/geom_dotplot.py +1 -1
  11. plotnine/geoms/geom_errorbar.py +2 -2
  12. plotnine/geoms/geom_errorbarh.py +2 -2
  13. plotnine/geoms/geom_hline.py +3 -2
  14. plotnine/geoms/geom_linerange.py +2 -2
  15. plotnine/geoms/geom_map.py +3 -3
  16. plotnine/geoms/geom_path.py +10 -11
  17. plotnine/geoms/geom_point.py +4 -5
  18. plotnine/geoms/geom_pointrange.py +3 -5
  19. plotnine/geoms/geom_polygon.py +2 -3
  20. plotnine/geoms/geom_raster.py +4 -5
  21. plotnine/geoms/geom_rect.py +3 -4
  22. plotnine/geoms/geom_ribbon.py +7 -7
  23. plotnine/geoms/geom_rug.py +1 -1
  24. plotnine/geoms/geom_segment.py +2 -2
  25. plotnine/geoms/geom_smooth.py +3 -3
  26. plotnine/geoms/geom_step.py +2 -2
  27. plotnine/geoms/geom_text.py +2 -3
  28. plotnine/geoms/geom_violin.py +4 -5
  29. plotnine/geoms/geom_vline.py +3 -2
  30. plotnine/guides/guides.py +1 -1
  31. plotnine/layer.py +18 -12
  32. plotnine/mapping/_eval_environment.py +1 -1
  33. plotnine/scales/scale_color.py +46 -14
  34. plotnine/scales/scale_continuous.py +5 -4
  35. plotnine/scales/scale_datetime.py +28 -14
  36. plotnine/scales/scale_discrete.py +2 -2
  37. plotnine/scales/scale_xy.py +2 -2
  38. plotnine/stats/smoothers.py +19 -19
  39. plotnine/stats/stat.py +15 -25
  40. plotnine/stats/stat_bin.py +2 -5
  41. plotnine/stats/stat_bin_2d.py +7 -9
  42. plotnine/stats/stat_bindot.py +5 -8
  43. plotnine/stats/stat_boxplot.py +5 -5
  44. plotnine/stats/stat_count.py +5 -9
  45. plotnine/stats/stat_density.py +5 -8
  46. plotnine/stats/stat_density_2d.py +12 -9
  47. plotnine/stats/stat_ecdf.py +6 -5
  48. plotnine/stats/stat_ellipse.py +5 -6
  49. plotnine/stats/stat_function.py +6 -8
  50. plotnine/stats/stat_hull.py +2 -3
  51. plotnine/stats/stat_identity.py +1 -2
  52. plotnine/stats/stat_pointdensity.py +4 -7
  53. plotnine/stats/stat_qq.py +45 -20
  54. plotnine/stats/stat_qq_line.py +15 -11
  55. plotnine/stats/stat_quantile.py +6 -7
  56. plotnine/stats/stat_sina.py +12 -14
  57. plotnine/stats/stat_smooth.py +7 -10
  58. plotnine/stats/stat_sum.py +1 -2
  59. plotnine/stats/stat_summary.py +6 -9
  60. plotnine/stats/stat_summary_bin.py +10 -13
  61. plotnine/stats/stat_unique.py +1 -2
  62. plotnine/stats/stat_ydensity.py +7 -10
  63. {plotnine-0.15.0a2.dist-info → plotnine-0.15.0a3.dist-info}/METADATA +3 -3
  64. {plotnine-0.15.0a2.dist-info → plotnine-0.15.0a3.dist-info}/RECORD +67 -67
  65. {plotnine-0.15.0a2.dist-info → plotnine-0.15.0a3.dist-info}/WHEEL +1 -1
  66. {plotnine-0.15.0a2.dist-info → plotnine-0.15.0a3.dist-info}/licenses/LICENSE +0 -0
  67. {plotnine-0.15.0a2.dist-info → plotnine-0.15.0a3.dist-info}/top_level.txt +0 -0
@@ -3,7 +3,7 @@ from __future__ import annotations
3
3
  import abc
4
4
  from dataclasses import dataclass
5
5
  from functools import cached_property
6
- from typing import TYPE_CHECKING
6
+ from typing import TYPE_CHECKING, cast
7
7
 
8
8
  import numpy as np
9
9
 
@@ -528,8 +528,9 @@ class ColumnsTree(LayoutTree):
528
528
  if self.bottom_tags_align:
529
529
  return
530
530
 
531
- values = max(self.bottom_tag_heights) - np.array(
532
- self.bottom_tag_heights
531
+ values = cast(
532
+ "Sequence[float]",
533
+ max(self.bottom_tag_heights) - np.array(self.bottom_tag_heights),
533
534
  )
534
535
  for item, value in zip(self.nodes, values):
535
536
  if isinstance(item, LayoutSpaces):
@@ -541,7 +542,10 @@ class ColumnsTree(LayoutTree):
541
542
  if self.top_tags_align:
542
543
  return
543
544
 
544
- values = max(self.top_tag_heights) - np.array(self.top_tag_heights)
545
+ values = cast(
546
+ "Sequence[float]",
547
+ max(self.top_tag_heights) - np.array(self.top_tag_heights),
548
+ )
545
549
  for item, value in zip(self.nodes, values):
546
550
  if isinstance(item, LayoutSpaces):
547
551
  item.t.tag_alignment = value
@@ -776,7 +780,10 @@ class RowsTree(LayoutTree):
776
780
  if self.left_tags_align:
777
781
  return
778
782
 
779
- values = max(self.left_tag_widths) - np.array(self.left_tag_widths)
783
+ values = cast(
784
+ "Sequence[float]",
785
+ max(self.left_tag_widths) - np.array(self.left_tag_widths),
786
+ )
780
787
  for item, value in zip(self.nodes, values):
781
788
  if isinstance(item, LayoutSpaces):
782
789
  item.l.tag_alignment = value
@@ -787,7 +794,10 @@ class RowsTree(LayoutTree):
787
794
  if self.right_tags_align:
788
795
  return
789
796
 
790
- values = max(self.right_tag_widths) - np.array(self.right_tag_widths)
797
+ values = cast(
798
+ "Sequence[float]",
799
+ max(self.right_tag_widths) - np.array(self.right_tag_widths),
800
+ )
791
801
  for item, value in zip(self.nodes, values):
792
802
  if isinstance(item, LayoutSpaces):
793
803
  item.r.tag_alignment = value
@@ -346,6 +346,8 @@ def _id_var(x: AnyArrayLike, drop: bool = False) -> list[int]:
346
346
  # NaNs are -1, we give them the highest code
347
347
  nan_code = -1
348
348
  new_nan_code = np.max(x.cat.codes) + 1
349
+ # TODO: We are assuming that x is of type Sequence[int|nan]
350
+ # is that accurate.
349
351
  lst = [val if val != nan_code else new_nan_code for val in x]
350
352
  else:
351
353
  lst = list(x.cat.codes + 1)
@@ -359,7 +361,7 @@ def _id_var(x: AnyArrayLike, drop: bool = False) -> list[int]:
359
361
  lst = match(x, levels)
360
362
  lst = [item + 1 for item in lst]
361
363
 
362
- return lst
364
+ return lst # pyright: ignore[reportReturnType]
363
365
 
364
366
 
365
367
  def join_keys(x, y, by=None):
@@ -513,7 +515,7 @@ def remove_missing(
513
515
  if finite:
514
516
  lst = [np.inf, -np.inf]
515
517
  to_replace = {v: lst for v in vars}
516
- data.replace(to_replace, np.nan, inplace=True) # pyright: ignore[reportArgumentType,reportCallIssue]
518
+ data.replace(to_replace, np.nan, inplace=True)
517
519
  txt = "non-finite"
518
520
  else:
519
521
  txt = "missing"
@@ -46,9 +46,7 @@ class _geom_logticks(geom_rug):
46
46
  }
47
47
  draw_legend = staticmethod(geom_path.draw_legend)
48
48
 
49
- def draw_layer(
50
- self, data: pd.DataFrame, layout: Layout, coord: coord, **params: Any
51
- ):
49
+ def draw_layer(self, data: pd.DataFrame, layout: Layout, coord: coord):
52
50
  """
53
51
  Draw ticks on every panel
54
52
  """
@@ -56,7 +54,7 @@ class _geom_logticks(geom_rug):
56
54
  ploc = pid - 1
57
55
  panel_params = layout.panel_params[ploc]
58
56
  ax = layout.axs[ploc]
59
- self.draw_panel(data, panel_params, coord, ax, **params)
57
+ self.draw_panel(data, panel_params, coord, ax)
60
58
 
61
59
  @staticmethod
62
60
  def _check_log_scale(
@@ -184,8 +182,8 @@ class _geom_logticks(geom_rug):
184
182
  panel_params: panel_view,
185
183
  coord: coord,
186
184
  ax: Axes,
187
- **params: Any,
188
185
  ):
186
+ params = self.params
189
187
  # Any passed data is ignored, the relevant data is created
190
188
  sides = params["sides"]
191
189
  lengths = params["lengths"]
@@ -203,9 +201,8 @@ class _geom_logticks(geom_rug):
203
201
  ):
204
202
  for position, length in zip(tick_positions, lengths):
205
203
  data = pd.DataFrame({axis: position, **_aesthetics})
206
- geom.draw_group(
207
- data, panel_params, coord, ax, length=length, **params
208
- )
204
+ params["length"] = length
205
+ geom.draw_group(data, panel_params, coord, ax, params)
209
206
 
210
207
  if isinstance(coord, coord_flip):
211
208
  tick_range_x = panel_params.y.range
@@ -96,9 +96,7 @@ class _geom_stripes(geom):
96
96
  }
97
97
  draw_legend = staticmethod(geom_polygon.draw_legend)
98
98
 
99
- def draw_layer(
100
- self, data: pd.DataFrame, layout: Layout, coord: coord, **params: Any
101
- ):
99
+ def draw_layer(self, data: pd.DataFrame, layout: Layout, coord: coord):
102
100
  """
103
101
  Draw stripes on every panel
104
102
  """
@@ -106,7 +104,7 @@ class _geom_stripes(geom):
106
104
  ploc = pid - 1
107
105
  panel_params = layout.panel_params[ploc]
108
106
  ax = layout.axs[ploc]
109
- self.draw_group(data, panel_params, coord, ax, **params)
107
+ self.draw_group(data, panel_params, coord, ax, self.params)
110
108
 
111
109
  @staticmethod
112
110
  def draw_group(
@@ -114,7 +112,7 @@ class _geom_stripes(geom):
114
112
  panel_params: panel_view,
115
113
  coord: coord,
116
114
  ax: Axes,
117
- **params: Any,
115
+ params: dict[str, Any],
118
116
  ):
119
117
  extend = params["extend"]
120
118
  fill_range = params["fill_range"]
@@ -195,4 +193,4 @@ class _geom_stripes(geom):
195
193
  }
196
194
  )
197
195
 
198
- return geom_rect.draw_group(data, panel_params, coord, ax, **params)
196
+ return geom_rect.draw_group(data, panel_params, coord, ax, params)
plotnine/geoms/geom.py CHANGED
@@ -171,6 +171,21 @@ class geom(ABC, metaclass=Register):
171
171
 
172
172
  return result
173
173
 
174
+ def setup_params(self, data: pd.DataFrame):
175
+ """
176
+ Override this method to verify and/or adjust parameters
177
+
178
+ Parameters
179
+ ----------
180
+ data :
181
+ Data
182
+
183
+ Returns
184
+ -------
185
+ out :
186
+ Parameters used by the geoms.
187
+ """
188
+
174
189
  def setup_data(self, data: pd.DataFrame) -> pd.DataFrame:
175
190
  """
176
191
  Modify the data before drawing takes place
@@ -261,9 +276,7 @@ class geom(ABC, metaclass=Register):
261
276
 
262
277
  return data
263
278
 
264
- def draw_layer(
265
- self, data: pd.DataFrame, layout: Layout, coord: coord, **params: Any
266
- ):
279
+ def draw_layer(self, data: pd.DataFrame, layout: Layout, coord: coord):
267
280
  """
268
281
  Draw layer across all panels
269
282
 
@@ -289,7 +302,7 @@ class geom(ABC, metaclass=Register):
289
302
  ploc = pdata["PANEL"].iloc[0] - 1
290
303
  panel_params = layout.panel_params[ploc]
291
304
  ax = layout.axs[ploc]
292
- self.draw_panel(pdata, panel_params, coord, ax, **params)
305
+ self.draw_panel(pdata, panel_params, coord, ax)
293
306
 
294
307
  def draw_panel(
295
308
  self,
@@ -297,7 +310,6 @@ class geom(ABC, metaclass=Register):
297
310
  panel_params: panel_view,
298
311
  coord: coord,
299
312
  ax: Axes,
300
- **params: Any,
301
313
  ):
302
314
  """
303
315
  Plot all groups
@@ -331,7 +343,7 @@ class geom(ABC, metaclass=Register):
331
343
  """
332
344
  for _, gdata in data.groupby("group"):
333
345
  gdata.reset_index(inplace=True, drop=True)
334
- self.draw_group(gdata, panel_params, coord, ax, **params)
346
+ self.draw_group(gdata, panel_params, coord, ax, self.params)
335
347
 
336
348
  @staticmethod
337
349
  def draw_group(
@@ -339,7 +351,7 @@ class geom(ABC, metaclass=Register):
339
351
  panel_params: panel_view,
340
352
  coord: coord,
341
353
  ax: Axes,
342
- **params: Any,
354
+ params: dict[str, Any],
343
355
  ):
344
356
  """
345
357
  Plot data belonging to a group.
@@ -376,7 +388,7 @@ class geom(ABC, metaclass=Register):
376
388
  panel_params: panel_view,
377
389
  coord: coord,
378
390
  ax: Axes,
379
- **params: Any,
391
+ params: dict[str, Any],
380
392
  ):
381
393
  """
382
394
  Plot data belonging to a unit.
@@ -102,7 +102,6 @@ class geom_abline(geom):
102
102
  panel_params: panel_view,
103
103
  coord: coord,
104
104
  ax: Axes,
105
- **params: Any,
106
105
  ):
107
106
  """
108
107
  Plot all groups
@@ -116,4 +115,6 @@ class geom_abline(geom):
116
115
 
117
116
  for _, gdata in data.groupby("group"):
118
117
  gdata.reset_index(inplace=True)
119
- geom_segment.draw_group(gdata, panel_params, coord, ax, **params)
118
+ geom_segment.draw_group(
119
+ gdata, panel_params, coord, ax, self.params
120
+ )
@@ -6,8 +6,6 @@ from ..doctools import document
6
6
  from .geom import geom
7
7
 
8
8
  if typing.TYPE_CHECKING:
9
- from typing import Any
10
-
11
9
  import pandas as pd
12
10
  from matplotlib.axes import Axes
13
11
 
@@ -39,7 +37,6 @@ class geom_blank(geom):
39
37
  panel_params: panel_view,
40
38
  coord: coord,
41
39
  ax: Axes,
42
- **params: Any,
43
40
  ):
44
41
  pass
45
42
 
@@ -183,7 +183,7 @@ class geom_boxplot(geom):
183
183
  panel_params: panel_view,
184
184
  coord: coord,
185
185
  ax: Axes,
186
- **params: Any,
186
+ params: dict[str, Any],
187
187
  ):
188
188
  def flat(*args: pd.Series[Any]) -> npt.NDArray[Any]:
189
189
  """Flatten list-likes"""
@@ -245,11 +245,11 @@ class geom_boxplot(geom):
245
245
  outliers["shape"] = outlier_value("shape")
246
246
  outliers["size"] = outlier_value("size")
247
247
  outliers["stroke"] = outlier_value("stroke")
248
- geom_point.draw_group(outliers, panel_params, coord, ax, **params)
248
+ geom_point.draw_group(outliers, panel_params, coord, ax, params)
249
249
 
250
250
  # plot
251
- geom_segment.draw_group(whiskers, panel_params, coord, ax, **params)
252
- geom_crossbar.draw_group(box, panel_params, coord, ax, **params)
251
+ geom_segment.draw_group(whiskers, panel_params, coord, ax, params)
252
+ geom_crossbar.draw_group(box, panel_params, coord, ax, params)
253
253
 
254
254
  @staticmethod
255
255
  def draw_legend(
@@ -78,7 +78,7 @@ class geom_crossbar(geom):
78
78
  panel_params: panel_view,
79
79
  coord: coord,
80
80
  ax: Axes,
81
- **params: Any,
81
+ params: dict[str, Any],
82
82
  ):
83
83
  y = data["y"]
84
84
  xmin = data["xmin"]
@@ -160,8 +160,8 @@ class geom_crossbar(geom):
160
160
  )
161
161
 
162
162
  copy_missing_columns(box, data)
163
- geom_polygon.draw_group(box, panel_params, coord, ax, **params)
164
- geom_segment.draw_group(middle, panel_params, coord, ax, **params)
163
+ geom_polygon.draw_group(box, panel_params, coord, ax, params)
164
+ geom_segment.draw_group(middle, panel_params, coord, ax, params)
165
165
 
166
166
  @staticmethod
167
167
  def draw_legend(
@@ -186,7 +186,7 @@ class geom_dotplot(geom):
186
186
  panel_params: panel_view,
187
187
  coord: coord,
188
188
  ax: Axes,
189
- **params: Any,
189
+ params: dict[str, Any],
190
190
  ):
191
191
  from matplotlib.collections import PatchCollection
192
192
  from matplotlib.patches import Ellipse
@@ -67,7 +67,7 @@ class geom_errorbar(geom):
67
67
  panel_params: panel_view,
68
68
  coord: coord,
69
69
  ax: Axes,
70
- **params: Any,
70
+ params: dict[str, Any],
71
71
  ):
72
72
  f = np.hstack
73
73
  # create (two horizontal bars) + vertical bar
@@ -81,4 +81,4 @@ class geom_errorbar(geom):
81
81
  )
82
82
 
83
83
  copy_missing_columns(bars, data)
84
- geom_segment.draw_group(bars, panel_params, coord, ax, **params)
84
+ geom_segment.draw_group(bars, panel_params, coord, ax, params)
@@ -67,7 +67,7 @@ class geom_errorbarh(geom):
67
67
  panel_params: panel_view,
68
68
  coord: coord,
69
69
  ax: Axes,
70
- **params: Any,
70
+ params: dict[str, Any],
71
71
  ):
72
72
  f = np.hstack
73
73
  # create (two vertical bars) + horizontal bar
@@ -81,4 +81,4 @@ class geom_errorbarh(geom):
81
81
  )
82
82
 
83
83
  copy_missing_columns(bars, data)
84
- geom_segment.draw_group(bars, panel_params, coord, ax, **params)
84
+ geom_segment.draw_group(bars, panel_params, coord, ax, params)
@@ -80,7 +80,6 @@ class geom_hline(geom):
80
80
  panel_params: panel_view,
81
81
  coord: coord,
82
82
  ax: Axes,
83
- **params: Any,
84
83
  ):
85
84
  """
86
85
  Plot all groups
@@ -94,4 +93,6 @@ class geom_hline(geom):
94
93
 
95
94
  for _, gdata in data.groupby("group"):
96
95
  gdata.reset_index(inplace=True)
97
- geom_segment.draw_group(gdata, panel_params, coord, ax, **params)
96
+ geom_segment.draw_group(
97
+ gdata, panel_params, coord, ax, self.params
98
+ )
@@ -49,7 +49,7 @@ class geom_linerange(geom):
49
49
  panel_params: panel_view,
50
50
  coord: coord,
51
51
  ax: Axes,
52
- **params: Any,
52
+ params: dict[str, Any],
53
53
  ):
54
54
  data.eval(
55
55
  """
@@ -59,4 +59,4 @@ class geom_linerange(geom):
59
59
  """,
60
60
  inplace=True,
61
61
  )
62
- geom_segment.draw_group(data, panel_params, coord, ax, **params)
62
+ geom_segment.draw_group(data, panel_params, coord, ax, params)
@@ -119,11 +119,11 @@ class geom_map(geom):
119
119
  panel_params: panel_view,
120
120
  coord: coord,
121
121
  ax: Axes,
122
- **params: Any,
123
122
  ):
124
123
  if not len(data):
125
124
  return
126
125
 
126
+ params = self.params
127
127
  data.loc[data["color"].isna(), "color"] = "none"
128
128
  data.loc[data["fill"].isna(), "fill"] = "none"
129
129
  data["fill"] = to_rgba(data["fill"], data["alpha"])
@@ -153,7 +153,7 @@ class geom_map(geom):
153
153
  for _, gdata in data.groupby("group"):
154
154
  gdata.reset_index(inplace=True, drop=True)
155
155
  gdata.is_copy = None
156
- geom_point.draw_group(gdata, panel_params, coord, ax, **params)
156
+ geom_point.draw_group(gdata, panel_params, coord, ax, params)
157
157
  elif geom_type == "MultiPoint":
158
158
  # Where n is the length of the dataframe (no. of multipoints),
159
159
  # m is the number of all points in all multipoints
@@ -168,7 +168,7 @@ class geom_map(geom):
168
168
  data = data.explode("points", ignore_index=True)
169
169
  data["x"] = [p[0] for p in data["points"]]
170
170
  data["y"] = [p[1] for p in data["points"]]
171
- geom_point.draw_group(data, panel_params, coord, ax, **params)
171
+ geom_point.draw_group(data, panel_params, coord, ax, params)
172
172
  elif geom_type in ("LineString", "MultiLineString"):
173
173
  from matplotlib.collections import LineCollection
174
174
 
@@ -107,7 +107,6 @@ class geom_path(geom):
107
107
  panel_params: panel_view,
108
108
  coord: coord,
109
109
  ax: Axes,
110
- **params: Any,
111
110
  ):
112
111
  if not any(data["group"].duplicated()):
113
112
  warn(
@@ -138,14 +137,14 @@ class geom_path(geom):
138
137
  ngroup = len(np.unique(data["group"].to_numpy()))
139
138
 
140
139
  constant = num_unique_rows == ngroup
141
- params["constant"] = constant
140
+ self.params["constant"] = constant
142
141
 
143
142
  if not constant:
144
- self.draw_group(data, panel_params, coord, ax, **params)
143
+ self.draw_group(data, panel_params, coord, ax, self.params)
145
144
  else:
146
145
  for _, gdata in data.groupby("group"):
147
146
  gdata.reset_index(inplace=True, drop=True)
148
- self.draw_group(gdata, panel_params, coord, ax, **params)
147
+ self.draw_group(gdata, panel_params, coord, ax, self.params)
149
148
 
150
149
  @staticmethod
151
150
  def draw_group(
@@ -153,7 +152,7 @@ class geom_path(geom):
153
152
  panel_params: panel_view,
154
153
  coord: coord,
155
154
  ax: Axes,
156
- **params: Any,
155
+ params: dict[str, Any],
157
156
  ):
158
157
  data = coord.transform(data, panel_params, munch=True)
159
158
  data["linewidth"] = data["size"] * SIZE_FACTOR
@@ -164,13 +163,13 @@ class geom_path(geom):
164
163
  constant = len(np.unique(data["group"].to_numpy())) == 1
165
164
 
166
165
  if not constant:
167
- _draw_segments(data, ax, **params)
166
+ _draw_segments(data, ax, params)
168
167
  else:
169
- _draw_lines(data, ax, **params)
168
+ _draw_lines(data, ax, params)
170
169
 
171
170
  if "arrow" in params and params["arrow"]:
172
171
  params["arrow"].draw(
173
- data, panel_params, coord, ax, constant=constant, **params
172
+ data, panel_params, coord, ax, params, constant=constant
174
173
  )
175
174
 
176
175
  @staticmethod
@@ -264,8 +263,8 @@ class arrow:
264
263
  panel_params: panel_view,
265
264
  coord: coord,
266
265
  ax: Axes,
266
+ params: dict[str, Any],
267
267
  constant: bool = True,
268
- **params: Any,
269
268
  ):
270
269
  """
271
270
  Draw arrows at the end(s) of the lines
@@ -454,7 +453,7 @@ class arrow:
454
453
  return paths
455
454
 
456
455
 
457
- def _draw_segments(data: pd.DataFrame, ax: Axes, **params: Any):
456
+ def _draw_segments(data: pd.DataFrame, ax: Axes, params: dict[str, Any]):
458
457
  """
459
458
  Draw independent line segments between all the
460
459
  points
@@ -493,7 +492,7 @@ def _draw_segments(data: pd.DataFrame, ax: Axes, **params: Any):
493
492
  ax.add_collection(coll)
494
493
 
495
494
 
496
- def _draw_lines(data: pd.DataFrame, ax: Axes, **params: Any):
495
+ def _draw_lines(data: pd.DataFrame, ax: Axes, params: dict[str, Any]):
497
496
  """
498
497
  Draw a path with the same characteristics from the
499
498
  first point to the last point
@@ -55,12 +55,11 @@ class geom_point(geom):
55
55
  panel_params: panel_view,
56
56
  coord: coord,
57
57
  ax: Axes,
58
- **params: Any,
59
58
  ):
60
59
  """
61
60
  Plot all groups
62
61
  """
63
- self.draw_group(data, panel_params, coord, ax, **params)
62
+ self.draw_group(data, panel_params, coord, ax, self.params)
64
63
 
65
64
  @staticmethod
66
65
  def draw_group(
@@ -68,13 +67,13 @@ class geom_point(geom):
68
67
  panel_params: panel_view,
69
68
  coord: coord,
70
69
  ax: Axes,
71
- **params: Any,
70
+ params: dict[str, Any],
72
71
  ):
73
72
  data = coord.transform(data, panel_params)
74
73
  units = "shape"
75
74
  for _, udata in data.groupby(units, dropna=False):
76
75
  udata.reset_index(inplace=True, drop=True)
77
- geom_point.draw_unit(udata, panel_params, coord, ax, **params)
76
+ geom_point.draw_unit(udata, panel_params, coord, ax, params)
78
77
 
79
78
  @staticmethod
80
79
  def draw_unit(
@@ -82,7 +81,7 @@ class geom_point(geom):
82
81
  panel_params: panel_view,
83
82
  coord: coord,
84
83
  ax: Axes,
85
- **params: Any,
84
+ params: dict[str, Any],
86
85
  ):
87
86
  # Our size is in 'points' while scatter wants
88
87
  # 'points^2'. The stroke is outside. And pi
@@ -58,14 +58,12 @@ class geom_pointrange(geom):
58
58
  panel_params: panel_view,
59
59
  coord: coord,
60
60
  ax: Axes,
61
- **params: Any,
61
+ params: dict[str, Any],
62
62
  ):
63
- geom_linerange.draw_group(
64
- data.copy(), panel_params, coord, ax, **params
65
- )
63
+ geom_linerange.draw_group(data.copy(), panel_params, coord, ax, params)
66
64
  data["size"] = data["size"] * params["fatten"]
67
65
  data["stroke"] = geom_point.DEFAULT_AES["stroke"]
68
- geom_point.draw_group(data, panel_params, coord, ax, **params)
66
+ geom_point.draw_group(data, panel_params, coord, ax, params)
69
67
 
70
68
  @staticmethod
71
69
  def draw_legend(
@@ -62,12 +62,11 @@ class geom_polygon(geom):
62
62
  panel_params: panel_view,
63
63
  coord: coord,
64
64
  ax: Axes,
65
- **params: Any,
66
65
  ):
67
66
  """
68
67
  Plot all groups
69
68
  """
70
- self.draw_group(data, panel_params, coord, ax, **params)
69
+ self.draw_group(data, panel_params, coord, ax, self.params)
71
70
 
72
71
  @staticmethod
73
72
  def draw_group(
@@ -75,7 +74,7 @@ class geom_polygon(geom):
75
74
  panel_params: panel_view,
76
75
  coord: coord,
77
76
  ax: Axes,
78
- **params: Any,
77
+ params: dict[str, Any],
79
78
  ):
80
79
  from matplotlib.collections import PolyCollection
81
80
 
@@ -155,7 +155,6 @@ class geom_raster(geom):
155
155
  panel_params: panel_view,
156
156
  coord: coord,
157
157
  ax: Axes,
158
- **params: Any,
159
158
  ):
160
159
  """
161
160
  Plot all groups
@@ -194,7 +193,7 @@ class geom_raster(geom):
194
193
  im = AxesImage(
195
194
  ax,
196
195
  data=X,
197
- interpolation=params["interpolation"],
196
+ interpolation=self.params["interpolation"],
198
197
  origin="upper",
199
198
  extent=(
200
199
  data["xmin"].min(),
@@ -202,8 +201,8 @@ class geom_raster(geom):
202
201
  data["ymin"].min(),
203
202
  data["ymax"].max(),
204
203
  ),
205
- rasterized=params["raster"],
206
- filterrad=params["filterrad"],
207
- zorder=params["zorder"],
204
+ rasterized=self.params["raster"],
205
+ filterrad=self.params["filterrad"],
206
+ zorder=self.params["zorder"],
208
207
  )
209
208
  ax.add_image(im)
@@ -52,7 +52,6 @@ class geom_rect(geom):
52
52
  panel_params: panel_view,
53
53
  coord: coord,
54
54
  ax: Axes,
55
- **params: Any,
56
55
  ):
57
56
  """
58
57
  Plot all groups
@@ -62,10 +61,10 @@ class geom_rect(geom):
62
61
  for _, gdata in data.groupby("group"):
63
62
  gdata.reset_index(inplace=True, drop=True)
64
63
  geom_polygon.draw_group(
65
- gdata, panel_params, coord, ax, **params
64
+ gdata, panel_params, coord, ax, self.params
66
65
  )
67
66
  else:
68
- self.draw_group(data, panel_params, coord, ax, **params)
67
+ self.draw_group(data, panel_params, coord, ax, self.params)
69
68
 
70
69
  @staticmethod
71
70
  def draw_group(
@@ -73,7 +72,7 @@ class geom_rect(geom):
73
72
  panel_params: panel_view,
74
73
  coord: coord,
75
74
  ax: Axes,
76
- **params: Any,
75
+ params: dict[str, Any],
77
76
  ):
78
77
  from matplotlib.collections import PolyCollection
79
78