lets-plot 4.7.0rc1__cp311-cp311-manylinux2014_aarch64.manylinux_2_17_aarch64.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.

Potentially problematic release.


This version of lets-plot might be problematic. Click here for more details.

Files changed (95) hide show
  1. lets_plot/__init__.py +283 -0
  2. lets_plot/_global_settings.py +196 -0
  3. lets_plot/_kbridge.py +141 -0
  4. lets_plot/_type_utils.py +133 -0
  5. lets_plot/_version.py +6 -0
  6. lets_plot/bistro/__init__.py +16 -0
  7. lets_plot/bistro/_plot2d_common.py +100 -0
  8. lets_plot/bistro/corr.py +447 -0
  9. lets_plot/bistro/im.py +196 -0
  10. lets_plot/bistro/joint.py +192 -0
  11. lets_plot/bistro/qq.py +207 -0
  12. lets_plot/bistro/residual.py +341 -0
  13. lets_plot/bistro/waterfall.py +333 -0
  14. lets_plot/export/__init__.py +6 -0
  15. lets_plot/export/ggsave_.py +141 -0
  16. lets_plot/frontend_context/__init__.py +8 -0
  17. lets_plot/frontend_context/_configuration.py +151 -0
  18. lets_plot/frontend_context/_frontend_ctx.py +16 -0
  19. lets_plot/frontend_context/_html_contexts.py +117 -0
  20. lets_plot/frontend_context/_intellij_python_json_ctx.py +38 -0
  21. lets_plot/frontend_context/_json_contexts.py +39 -0
  22. lets_plot/frontend_context/_jupyter_notebook_ctx.py +119 -0
  23. lets_plot/frontend_context/_mime_types.py +7 -0
  24. lets_plot/frontend_context/_static_html_page_ctx.py +27 -0
  25. lets_plot/frontend_context/_static_svg_ctx.py +26 -0
  26. lets_plot/frontend_context/_webbr_html_page_ctx.py +29 -0
  27. lets_plot/frontend_context/sandbox.py +5 -0
  28. lets_plot/geo_data/__init__.py +19 -0
  29. lets_plot/geo_data/core.py +331 -0
  30. lets_plot/geo_data/geocoder.py +977 -0
  31. lets_plot/geo_data/geocodes.py +512 -0
  32. lets_plot/geo_data/gis/__init__.py +0 -0
  33. lets_plot/geo_data/gis/fluent_dict.py +201 -0
  34. lets_plot/geo_data/gis/geocoding_service.py +42 -0
  35. lets_plot/geo_data/gis/geometry.py +91 -0
  36. lets_plot/geo_data/gis/json_request.py +232 -0
  37. lets_plot/geo_data/gis/json_response.py +308 -0
  38. lets_plot/geo_data/gis/request.py +492 -0
  39. lets_plot/geo_data/gis/response.py +247 -0
  40. lets_plot/geo_data/livemap_helper.py +65 -0
  41. lets_plot/geo_data/to_geo_data_frame.py +141 -0
  42. lets_plot/geo_data/type_assertion.py +34 -0
  43. lets_plot/geo_data_internals/__init__.py +4 -0
  44. lets_plot/geo_data_internals/constants.py +13 -0
  45. lets_plot/geo_data_internals/utils.py +33 -0
  46. lets_plot/mapping.py +115 -0
  47. lets_plot/package_data/lets-plot.min.js +3 -0
  48. lets_plot/plot/__init__.py +64 -0
  49. lets_plot/plot/_global_theme.py +14 -0
  50. lets_plot/plot/annotation.py +290 -0
  51. lets_plot/plot/coord.py +242 -0
  52. lets_plot/plot/core.py +1060 -0
  53. lets_plot/plot/expand_limits_.py +78 -0
  54. lets_plot/plot/facet.py +206 -0
  55. lets_plot/plot/font_features.py +71 -0
  56. lets_plot/plot/geom.py +8839 -0
  57. lets_plot/plot/geom_extras.py +53 -0
  58. lets_plot/plot/geom_function_.py +216 -0
  59. lets_plot/plot/geom_imshow_.py +392 -0
  60. lets_plot/plot/geom_livemap_.py +310 -0
  61. lets_plot/plot/ggbunch_.py +96 -0
  62. lets_plot/plot/gggrid_.py +126 -0
  63. lets_plot/plot/ggtb_.py +55 -0
  64. lets_plot/plot/guide.py +229 -0
  65. lets_plot/plot/label.py +187 -0
  66. lets_plot/plot/marginal_layer.py +181 -0
  67. lets_plot/plot/plot.py +244 -0
  68. lets_plot/plot/pos.py +320 -0
  69. lets_plot/plot/sampling.py +338 -0
  70. lets_plot/plot/sandbox_.py +26 -0
  71. lets_plot/plot/scale.py +3577 -0
  72. lets_plot/plot/scale_colormap_mpl.py +297 -0
  73. lets_plot/plot/scale_convenience.py +155 -0
  74. lets_plot/plot/scale_identity_.py +658 -0
  75. lets_plot/plot/scale_position.py +1342 -0
  76. lets_plot/plot/series_meta.py +203 -0
  77. lets_plot/plot/stat.py +581 -0
  78. lets_plot/plot/subplots.py +322 -0
  79. lets_plot/plot/subplots_util.py +24 -0
  80. lets_plot/plot/theme_.py +772 -0
  81. lets_plot/plot/theme_set.py +393 -0
  82. lets_plot/plot/tooltip.py +486 -0
  83. lets_plot/plot/util.py +237 -0
  84. lets_plot/settings_utils.py +244 -0
  85. lets_plot/tilesets.py +429 -0
  86. lets_plot-4.7.0rc1.dist-info/METADATA +196 -0
  87. lets_plot-4.7.0rc1.dist-info/RECORD +95 -0
  88. lets_plot-4.7.0rc1.dist-info/WHEEL +6 -0
  89. lets_plot-4.7.0rc1.dist-info/licenses/LICENSE +21 -0
  90. lets_plot-4.7.0rc1.dist-info/licenses/licenses/LICENSE.FreeType +166 -0
  91. lets_plot-4.7.0rc1.dist-info/licenses/licenses/LICENSE.ImageMagick +106 -0
  92. lets_plot-4.7.0rc1.dist-info/licenses/licenses/LICENSE.expat +21 -0
  93. lets_plot-4.7.0rc1.dist-info/licenses/licenses/LICENSE.fontconfig +200 -0
  94. lets_plot-4.7.0rc1.dist-info/top_level.txt +2 -0
  95. lets_plot_kotlin_bridge.cpython-311-aarch64-linux-gnu.so +0 -0
lets_plot/plot/stat.py ADDED
@@ -0,0 +1,581 @@
1
+ # Copyright (c) 2023. JetBrains s.r.o.
2
+ # Use of this source code is governed by the MIT license that can be found in the LICENSE file.
3
+ from .geom import _geom
4
+
5
+ #
6
+ # Stats - functions, drawing attention to the statistical transformation rather than the visual appearance.
7
+ #
8
+ __all__ = ['stat_summary', 'stat_summary_bin', 'stat_ecdf', 'stat_sum']
9
+
10
+
11
+ def stat_summary(mapping=None, *, data=None, geom=None,
12
+ position=None, show_legend=None, inherit_aes=None,
13
+ sampling=None, tooltips=None,
14
+ orientation=None,
15
+ fun=None, fun_min=None, fun_max=None,
16
+ quantiles=None,
17
+ color_by=None, fill_by=None,
18
+ **other_args):
19
+ """
20
+ Display the aggregated values of a single continuous variable grouped along the x axis.
21
+
22
+ Parameters
23
+ ----------
24
+ mapping : `FeatureSpec`
25
+ Set of aesthetic mappings created by `aes()` function.
26
+ Aesthetic mappings describe the way that variables in the data are
27
+ mapped to plot "aesthetics".
28
+ data : dict or Pandas or Polars `DataFrame`
29
+ The data to be displayed in this layer. If None, the default, the data
30
+ is inherited from the plot data as specified in the call to ggplot.
31
+ geom : str, default='pointrange'
32
+ The geometry to display the summary stat for this layer, as a string.
33
+ position : str or `FeatureSpec`, default='identity'
34
+ Position adjustment.
35
+ Either a position adjustment name: 'dodge', 'jitter', 'nudge', 'jitterdodge', 'fill',
36
+ 'stack' or 'identity', or the result of calling a position adjustment function (e.g., `position_dodge()` etc.).
37
+ show_legend : bool, default=True
38
+ False - do not show legend for this layer.
39
+ inherit_aes : bool, default=True
40
+ False - do not combine the layer aesthetic mappings with the plot shared mappings.
41
+ sampling : `FeatureSpec`
42
+ Result of the call to the `sampling_xxx()` function.
43
+ To prevent any sampling for this layer pass value "none" (string "none").
44
+ tooltips : `layer_tooltips`
45
+ Result of the call to the `layer_tooltips()` function.
46
+ Specify appearance, style and content.
47
+ Set tooltips='none' to hide tooltips from the layer.
48
+ orientation : str
49
+ Specify the axis that the layer's stat and geom should run along.
50
+ The default value (None) automatically determines the orientation based on the aesthetic mapping.
51
+ If the automatic detection doesn't work, it can be set explicitly by specifying the 'x' or 'y' orientation.
52
+ fun : {'count', 'sum', 'mean', 'median', 'min', 'max', 'lq', 'mq', 'uq'}, default='mean'
53
+ Name of function computing stat variable '..y..'.
54
+ Names 'lq', 'mq', 'uq' corresponds to lower, middle and upper quantiles, default=[0.25, 0.5, 0.75].
55
+ fun_min : {'count', 'sum', 'mean', 'median', 'min', 'max', 'lq', 'mq', 'uq'}, default='min'
56
+ Name of function computing stat variable '..ymin..'.
57
+ Names 'lq', 'mq', 'uq' corresponds to lower, middle and upper quantiles, default=[0.25, 0.5, 0.75].
58
+ fun_max : {'count', 'sum', 'mean', 'median', 'min', 'max', 'lq', 'mq', 'uq'}, default='max'
59
+ Name of function computing stat variable '..ymax..'.
60
+ Names 'lq', 'mq', 'uq' corresponds to lower, middle and upper quantiles, default=[0.25, 0.5, 0.75].
61
+ quantiles : list of float, default=[0.25, 0.5, 0.75]
62
+ A list of probabilities defining the quantile functions 'lq', 'mq' and 'uq'.
63
+ Must contain exactly 3 values between 0 and 1.
64
+ color_by : {'fill', 'color', 'paint_a', 'paint_b', 'paint_c'}, default='color'
65
+ Define the color aesthetic for the geometry.
66
+ fill_by : {'fill', 'color', 'paint_a', 'paint_b', 'paint_c'}, default='fill'
67
+ Define the fill aesthetic for the geometry.
68
+ other_args
69
+ Other arguments passed on to the layer.
70
+ These are often aesthetics settings used to set an aesthetic to a fixed value,
71
+ like color='red', fill='blue', size=3 or shape=21.
72
+ They may also be parameters to the paired geom/stat.
73
+
74
+ Returns
75
+ -------
76
+ `LayerSpec`
77
+ Geom object specification.
78
+
79
+ Notes
80
+ -----
81
+ Computed variables:
82
+
83
+ - ..y.. : result of calculating of `fun`.
84
+ - ..ymin.. : result of calculating of `fun_min`.
85
+ - ..ymax.. : result of calculating of `fun_max`.
86
+
87
+ ----
88
+
89
+ To hide axis tooltips, set 'blank' or the result of `element_blank()`
90
+ to the `axis_tooltip` or `axis_tooltip_x` parameter of the `theme()`.
91
+
92
+ Examples
93
+ --------
94
+ .. jupyter-execute::
95
+ :linenos:
96
+ :emphasize-lines: 9
97
+
98
+ import numpy as np
99
+ from lets_plot import *
100
+ LetsPlot.setup_html()
101
+ n = 100
102
+ np.random.seed(42)
103
+ x = np.random.choice(['a', 'b', 'c'], size=n)
104
+ y = np.random.normal(size=n)
105
+ ggplot({'x': x, 'y': y}, aes(x='x', y='y')) + \\
106
+ stat_summary()
107
+
108
+ |
109
+
110
+ .. jupyter-execute::
111
+ :linenos:
112
+ :emphasize-lines: 9
113
+
114
+ import numpy as np
115
+ from lets_plot import *
116
+ LetsPlot.setup_html()
117
+ n = 100
118
+ np.random.seed(42)
119
+ x = np.random.choice(['a', 'b', 'c'], size=n)
120
+ y = np.random.normal(size=n)
121
+ ggplot({'x': x, 'y': y}, aes(x='x', y='y', fill='x')) + \\
122
+ stat_summary(geom='crossbar', fatten=5)
123
+
124
+ |
125
+
126
+ .. jupyter-execute::
127
+ :linenos:
128
+ :emphasize-lines: 9-11
129
+
130
+ import numpy as np
131
+ from lets_plot import *
132
+ LetsPlot.setup_html()
133
+ n = 100
134
+ np.random.seed(42)
135
+ x = np.random.choice(['a', 'b', 'c'], size=n)
136
+ y = np.random.normal(size=n)
137
+ ggplot({'x': x, 'y': y}, aes(x='x', y='y')) + \\
138
+ stat_summary(position=position_nudge(x=-.1), color="red") + \\
139
+ stat_summary(fun='mq', fun_min='lq', fun_max='uq', quantiles=[.1, .5, .9], \\
140
+ position=position_nudge(x=.1), color="blue")
141
+
142
+ """
143
+ summary_geom = geom if geom is not None else 'pointrange'
144
+ return _geom(summary_geom,
145
+ mapping=mapping,
146
+ data=data,
147
+ stat='summary',
148
+ position=position,
149
+ show_legend=show_legend,
150
+ inherit_aes=inherit_aes,
151
+ sampling=sampling,
152
+ tooltips=tooltips,
153
+ orientation=orientation,
154
+ fun=fun, fun_min=fun_min, fun_max=fun_max,
155
+ quantiles=quantiles,
156
+ color_by=color_by, fill_by=fill_by,
157
+ **other_args)
158
+
159
+
160
+ def stat_summary_bin(mapping=None, *, data=None, geom=None,
161
+ position=None, show_legend=None, inherit_aes=None,
162
+ sampling=None, tooltips=None,
163
+ orientation=None,
164
+ fun=None, fun_min=None, fun_max=None,
165
+ quantiles=None,
166
+ bins=None, binwidth=None,
167
+ center=None, boundary=None,
168
+ color_by=None, fill_by=None,
169
+ **other_args):
170
+ """
171
+ Display a distribution by dividing variable mapped to x axis into bins
172
+ and applying aggregation functions to each bin.
173
+
174
+ Parameters
175
+ ----------
176
+ mapping : `FeatureSpec`
177
+ Set of aesthetic mappings created by `aes()` function.
178
+ Aesthetic mappings describe the way that variables in the data are
179
+ mapped to plot "aesthetics".
180
+ data : dict or Pandas or Polars `DataFrame`
181
+ The data to be displayed in this layer. If None, the default, the data
182
+ is inherited from the plot data as specified in the call to ggplot.
183
+ geom : str, default='pointrange'
184
+ The geometry to display the summary stat for this layer, as a string.
185
+ position : str or `FeatureSpec`, default='identity'
186
+ Position adjustment.
187
+ Either a position adjustment name: 'dodge', 'jitter', 'nudge', 'jitterdodge', 'fill',
188
+ 'stack' or 'identity', or the result of calling a position adjustment function (e.g., `position_dodge()` etc.).
189
+ show_legend : bool, default=True
190
+ False - do not show legend for this layer.
191
+ inherit_aes : bool, default=True
192
+ False - do not combine the layer aesthetic mappings with the plot shared mappings.
193
+ sampling : `FeatureSpec`
194
+ Result of the call to the `sampling_xxx()` function.
195
+ To prevent any sampling for this layer pass value "none" (string "none").
196
+ tooltips : `layer_tooltips`
197
+ Result of the call to the `layer_tooltips()` function.
198
+ Specify appearance, style and content.
199
+ Set tooltips='none' to hide tooltips from the layer.
200
+ orientation : str, default='x'
201
+ Specify the axis that the layer's stat and geom should run along.
202
+ Possible values: 'x', 'y'.
203
+ fun : {'count', 'sum', 'mean', 'median', 'min', 'max', 'lq', 'mq', 'uq'}, default='mean'
204
+ Name of function computing stat variable '..y..'.
205
+ Names 'lq', 'mq', 'uq' corresponds to lower, middle and upper quantiles, default=[0.25, 0.5, 0.75].
206
+ fun_min : {'count', 'sum', 'mean', 'median', 'min', 'max', 'lq', 'mq', 'uq'}, default='min'
207
+ Name of function computing stat variable '..ymin..'.
208
+ Names 'lq', 'mq', 'uq' corresponds to lower, middle and upper quantiles, default=[0.25, 0.5, 0.75].
209
+ fun_max : {'count', 'sum', 'mean', 'median', 'min', 'max', 'lq', 'mq', 'uq'}, default='max'
210
+ Name of function computing stat variable '..ymax..'.
211
+ Names 'lq', 'mq', 'uq' corresponds to lower, middle and upper quantiles, default=[0.25, 0.5, 0.75].
212
+ quantiles : list of float, default=[0.25, 0.5, 0.75]
213
+ A list of probabilities defining the quantile functions 'lq', 'mq' and 'uq'.
214
+ Must contain exactly 3 values between 0 and 1.
215
+ bins : int, default=30
216
+ Number of bins. Overridden by `binwidth`.
217
+ binwidth : float
218
+ The width of the bins. The default is to use bin widths that cover
219
+ the range of the data. You should always override this value,
220
+ exploring multiple widths to find the best to illustrate the stories in your data.
221
+ center : float
222
+ Specify x-value to align bin centers to.
223
+ boundary : float
224
+ Specify x-value to align bin boundary (i.e. point between bins) to.
225
+ color_by : {'fill', 'color', 'paint_a', 'paint_b', 'paint_c'}, default='color'
226
+ Define the color aesthetic for the geometry.
227
+ fill_by : {'fill', 'color', 'paint_a', 'paint_b', 'paint_c'}, default='fill'
228
+ Define the fill aesthetic for the geometry.
229
+ other_args
230
+ Other arguments passed on to the layer.
231
+ These are often aesthetics settings used to set an aesthetic to a fixed value,
232
+ like color='red', fill='blue', size=3 or shape=21.
233
+ They may also be parameters to the paired geom/stat.
234
+
235
+ Returns
236
+ -------
237
+ `LayerSpec`
238
+ Geom object specification.
239
+
240
+ Notes
241
+ -----
242
+ Computed variables:
243
+
244
+ - ..y.. : result of calculating of `fun`.
245
+ - ..ymin.. : result of calculating of `fun_min`.
246
+ - ..ymax.. : result of calculating of `fun_max`.
247
+
248
+ ----
249
+
250
+ To hide axis tooltips, set 'blank' or the result of `element_blank()`
251
+ to the `axis_tooltip` or `axis_tooltip_x` parameter of the `theme()`.
252
+
253
+ Examples
254
+ --------
255
+ .. jupyter-execute::
256
+ :linenos:
257
+ :emphasize-lines: 9
258
+
259
+ import numpy as np
260
+ from lets_plot import *
261
+ LetsPlot.setup_html()
262
+ n = 100
263
+ np.random.seed(42)
264
+ x = np.random.uniform(size=n)
265
+ y = np.random.normal(size=n)
266
+ ggplot({'x': x, 'y': y}, aes(x='x', y='y')) + \\
267
+ stat_summary_bin()
268
+
269
+ |
270
+
271
+ .. jupyter-execute::
272
+ :linenos:
273
+ :emphasize-lines: 10
274
+
275
+ import numpy as np
276
+ from lets_plot import *
277
+ LetsPlot.setup_html()
278
+ n = 100
279
+ np.random.seed(42)
280
+ x = np.random.uniform(size=n)
281
+ y = np.random.normal(size=n)
282
+ g = np.random.choice(["A", "B"], size=n)
283
+ ggplot({'x': x, 'y': y, 'g': g}, aes(x='x', y='y', fill='g')) + \\
284
+ stat_summary_bin(geom='crossbar', bins=6, fatten=5, position='dodge')
285
+
286
+ |
287
+
288
+ .. jupyter-execute::
289
+ :linenos:
290
+ :emphasize-lines: 9-10
291
+
292
+ import numpy as np
293
+ from lets_plot import *
294
+ LetsPlot.setup_html()
295
+ n = 100
296
+ np.random.seed(42)
297
+ x = np.random.uniform(size=n)
298
+ y = np.random.normal(size=n)
299
+ ggplot({'x': x, 'y': y}, aes(x='x', y='y')) + \\
300
+ stat_summary_bin(fun='mq', fun_min='lq', fun_max='uq', geom='crossbar', \\
301
+ bins=11, width=1, quantiles=[.05, .5, .95], boundary=0) + \\
302
+ geom_point()
303
+
304
+ """
305
+ summary_bin_geom = geom if geom is not None else 'pointrange'
306
+ return _geom(summary_bin_geom,
307
+ mapping=mapping,
308
+ data=data,
309
+ stat='summarybin',
310
+ position=position,
311
+ show_legend=show_legend,
312
+ inherit_aes=inherit_aes,
313
+ sampling=sampling,
314
+ tooltips=tooltips,
315
+ orientation=orientation,
316
+ fun=fun, fun_min=fun_min, fun_max=fun_max,
317
+ quantiles=quantiles,
318
+ bins=bins, binwidth=binwidth,
319
+ center=center, boundary=boundary,
320
+ color_by=color_by, fill_by=fill_by,
321
+ **other_args)
322
+
323
+
324
+ def stat_ecdf(mapping=None, *, data=None, geom=None,
325
+ position=None, show_legend=None, inherit_aes=None,
326
+ sampling=None, tooltips=None,
327
+ orientation=None,
328
+ n=None, pad=None,
329
+ color_by=None,
330
+ **other_args):
331
+ """
332
+ Display the empirical cumulative distribution function.
333
+
334
+ Parameters
335
+ ----------
336
+ mapping : `FeatureSpec`
337
+ Set of aesthetic mappings created by `aes()` function.
338
+ Aesthetic mappings describe the way that variables in the data are
339
+ mapped to plot "aesthetics".
340
+ data : dict or Pandas or Polars `DataFrame`
341
+ The data to be displayed in this layer. If None, the default, the data
342
+ is inherited from the plot data as specified in the call to ggplot.
343
+ geom : str, default='step'
344
+ The geometry to display the ecdf stat for this layer, as a string.
345
+ position : str or `FeatureSpec`, default='identity'
346
+ Position adjustment.
347
+ Either a position adjustment name: 'dodge', 'jitter', 'nudge', 'jitterdodge', 'fill',
348
+ 'stack' or 'identity', or the result of calling a position adjustment function (e.g., `position_dodge()` etc.).
349
+ show_legend : bool, default=True
350
+ False - do not show legend for this layer.
351
+ inherit_aes : bool, default=True
352
+ False - do not combine the layer aesthetic mappings with the plot shared mappings.
353
+ sampling : `FeatureSpec`
354
+ Result of the call to the `sampling_xxx()` function.
355
+ To prevent any sampling for this layer pass value "none" (string "none").
356
+ tooltips : `layer_tooltips`
357
+ Result of the call to the `layer_tooltips()` function.
358
+ Specify appearance, style and content.
359
+ Set tooltips='none' to hide tooltips from the layer.
360
+ orientation : str, default='x'
361
+ Specify the axis that the layer's stat and geom should run along.
362
+ Possible values: 'x', 'y'.
363
+ n : int
364
+ If None, do not interpolate.
365
+ If not None, this is the number of points to interpolate with.
366
+ pad : bool, default=True
367
+ If geometry is `'step'` and `pad=True`, then the points at the ends:
368
+ (-inf, 0) and (inf, 1) are added to the ecdf.
369
+ color_by : {'fill', 'color', 'paint_a', 'paint_b', 'paint_c'}, default='color'
370
+ Define the color aesthetic for the geometry.
371
+ other_args
372
+ Other arguments passed on to the layer.
373
+ These are often aesthetics settings used to set an aesthetic to a fixed value,
374
+ like color='red', fill='blue', size=3 or shape=21.
375
+ They may also be parameters to the paired geom/stat.
376
+
377
+ Returns
378
+ -------
379
+ `LayerSpec`
380
+ Geom object specification.
381
+
382
+ Notes
383
+ -----
384
+ `stat_ecdf()` understands the following aesthetics mappings:
385
+
386
+ - x : x-axis coordinates.
387
+ - y : y-axis coordinates.
388
+
389
+ In addition, you can use any aesthetics, available for the geometry defined by the `geom` parameter.
390
+
391
+ ----
392
+
393
+ To hide axis tooltips, set 'blank' or the result of `element_blank()`
394
+ to the `axis_tooltip` or `axis_tooltip_x` parameter of the `theme()`.
395
+
396
+ Examples
397
+ --------
398
+ .. jupyter-execute::
399
+ :linenos:
400
+ :emphasize-lines: 7
401
+
402
+ import numpy as np
403
+ from lets_plot import *
404
+ LetsPlot.setup_html()
405
+ n = 100
406
+ np.random.seed(42)
407
+ x = np.random.normal(size=n)
408
+ ggplot({'x': x}, aes(x='x')) + stat_ecdf()
409
+
410
+ |
411
+
412
+ .. jupyter-execute::
413
+ :linenos:
414
+ :emphasize-lines: 14-15
415
+
416
+ import numpy as np
417
+ from lets_plot import *
418
+ LetsPlot.setup_html()
419
+ n = 100
420
+ np.random.seed(42)
421
+ x = np.concatenate([
422
+ np.random.normal(size=n),
423
+ np.random.uniform(size=n),
424
+ np.random.poisson(size=n),
425
+ ])
426
+ g = ["A"] * n + ["B"] * n + ["C"] * n
427
+ p = ggplot({'x': x, 'g': g}, aes(x='x', color='g'))
428
+ gggrid([
429
+ p + stat_ecdf() + ggtitle("pad=True (default)"),
430
+ p + stat_ecdf(pad=False) + ggtitle("pad=False")
431
+ ])
432
+
433
+ |
434
+
435
+ .. jupyter-execute::
436
+ :linenos:
437
+ :emphasize-lines: 8-9
438
+
439
+ import numpy as np
440
+ from lets_plot import *
441
+ LetsPlot.setup_html()
442
+ n = 500
443
+ np.random.seed(42)
444
+ x = np.random.normal(size=n)
445
+ ggplot() + \\
446
+ stat_ecdf(aes(x=x), geom='point', n=20, \\
447
+ shape=21, color="#f03b20", fill="#ffeda0")
448
+
449
+ """
450
+ ecdf_geom = geom if geom is not None else 'step'
451
+ ecdf_pad = pad if pad is not None else True
452
+ return _geom(ecdf_geom,
453
+ mapping=mapping,
454
+ data=data,
455
+ stat='ecdf',
456
+ position=position,
457
+ show_legend=show_legend,
458
+ inherit_aes=inherit_aes,
459
+ sampling=sampling,
460
+ tooltips=tooltips,
461
+ orientation=orientation,
462
+ n=n,
463
+ pad=ecdf_pad,
464
+ color_by=color_by,
465
+ **other_args)
466
+
467
+
468
+ def stat_sum(mapping=None, *, data=None, geom=None, position=None, show_legend=None, inherit_aes=None,
469
+ sampling=None, tooltips=None,
470
+ color_by=None, fill_by=None,
471
+ **other_args):
472
+ """
473
+ Sum unique values.
474
+
475
+ Parameters
476
+ ----------
477
+ mapping : `FeatureSpec`
478
+ Set of aesthetic mappings created by `aes()` function.
479
+ Aesthetic mappings describe the way that variables in the data are
480
+ mapped to plot "aesthetics".
481
+ data : dict or Pandas or Polars `DataFrame`
482
+ The data to be displayed in this layer. If None, the default, the data
483
+ is inherited from the plot data as specified in the call to ggplot.
484
+ geom : str, default='point'
485
+ The geometry to display the sum stat for this layer, as a string.
486
+ position : str or `FeatureSpec`, default='identity'
487
+ Position adjustment.
488
+ Either a position adjustment name: 'dodge', 'jitter', 'nudge', 'jitterdodge', 'fill',
489
+ 'stack' or 'identity', or the result of calling a position adjustment function (e.g., `position_dodge()` etc.).
490
+ show_legend : bool, default=True
491
+ False - do not show legend for this layer.
492
+ inherit_aes : bool, default=True
493
+ False - do not combine the layer aesthetic mappings with the plot shared mappings.
494
+ sampling : `FeatureSpec`
495
+ Result of the call to the `sampling_xxx()` function.
496
+ To prevent any sampling for this layer pass value "none" (string "none").
497
+ tooltips : `layer_tooltips`
498
+ Result of the call to the `layer_tooltips()` function.
499
+ Specify appearance, style and content.
500
+ Set tooltips='none' to hide tooltips from the layer.
501
+ color_by : {'fill', 'color', 'paint_a', 'paint_b', 'paint_c'}, default='color'
502
+ Define the color aesthetic for the geometry.
503
+ fill_by : {'fill', 'color', 'paint_a', 'paint_b', 'paint_c'}, default='fill'
504
+ Define the fill aesthetic for the geometry.
505
+ other_args
506
+ Other arguments passed on to the layer.
507
+ These are often aesthetics settings used to set an aesthetic to a fixed value,
508
+ like color='red', fill='blue', size=3 or shape=21.
509
+ They may also be parameters to the paired geom/stat.
510
+
511
+ Returns
512
+ -------
513
+ `LayerSpec`
514
+ Geom object specification.
515
+
516
+ Notes
517
+ -----
518
+ Computed variables:
519
+
520
+ - ..n.. : number of points with same x-axis and y-axis coordinates.
521
+ - ..prop.. : proportion of points with same x-axis and y-axis coordinates.
522
+ - ..proppct.. : proportion of points with same x-axis and y-axis coordinates in percent.
523
+
524
+ `stat_sum()` understands the following aesthetics mappings:
525
+
526
+ - x : x-axis coordinates.
527
+ - y : y-axis coordinates.
528
+
529
+ In addition, you can use any aesthetics, available for the geometry defined by the `geom` parameter.
530
+
531
+ ----
532
+
533
+ To hide axis tooltips, set 'blank' or the result of `element_blank()`
534
+ to the `axis_tooltip`, `axis_tooltip_x` or `axis_tooltip_y` parameter of the `theme()`.
535
+
536
+ Examples
537
+ --------
538
+ .. jupyter-execute::
539
+ :linenos:
540
+ :emphasize-lines: 9
541
+
542
+ import numpy as np
543
+ from lets_plot import *
544
+ LetsPlot.setup_html()
545
+ n = 50
546
+ np.random.seed(42)
547
+ x = [round(it) for it in np.random.normal(0, 1.5, size=n)]
548
+ y = [round(it) for it in np.random.normal(0, 1.5, size=n)]
549
+ ggplot({'x': x, 'y': y}, aes(x=as_discrete('x', order=1), y=as_discrete('y', order=1))) + \\
550
+ stat_sum()
551
+
552
+ |
553
+
554
+ .. jupyter-execute::
555
+ :linenos:
556
+ :emphasize-lines: 9
557
+
558
+ import numpy as np
559
+ from lets_plot import *
560
+ LetsPlot.setup_html()
561
+ n = 50
562
+ np.random.seed(42)
563
+ x = [round(it) for it in np.random.normal(0, 1.5, size=n)]
564
+ y = [round(it) for it in np.random.normal(0, 1.5, size=n)]
565
+ ggplot({'x': x, 'y': y}, aes(x=as_discrete('x', order=1), y=as_discrete('y', order=1))) + \\
566
+ stat_sum(aes(size='..prop..', group='x'))
567
+
568
+ """
569
+ sum_geom = 'point' if geom is None else geom
570
+ return _geom(sum_geom,
571
+ mapping=mapping,
572
+ data=data,
573
+ stat='sum',
574
+ position=position,
575
+ show_legend=show_legend,
576
+ inherit_aes=inherit_aes,
577
+ sampling=sampling,
578
+ tooltips=tooltips,
579
+ color_by=color_by,
580
+ fill_by=fill_by,
581
+ **other_args)