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