lets-plot 4.6.0rc1__cp312-cp312-macosx_10_15_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.

Potentially problematic release.


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

Files changed (91) hide show
  1. lets_plot/__init__.py +283 -0
  2. lets_plot/_global_settings.py +191 -0
  3. lets_plot/_kbridge.py +134 -0
  4. lets_plot/_type_utils.py +110 -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 +252 -0
  14. lets_plot/export/__init__.py +6 -0
  15. lets_plot/export/ggsave_.py +133 -0
  16. lets_plot/frontend_context/__init__.py +8 -0
  17. lets_plot/frontend_context/_configuration.py +144 -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 +18 -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 +2 -0
  48. lets_plot/plot/__init__.py +64 -0
  49. lets_plot/plot/_global_theme.py +14 -0
  50. lets_plot/plot/annotation.py +233 -0
  51. lets_plot/plot/coord.py +242 -0
  52. lets_plot/plot/core.py +943 -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 +8160 -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 +401 -0
  60. lets_plot/plot/geom_livemap_.py +330 -0
  61. lets_plot/plot/ggbunch_.py +96 -0
  62. lets_plot/plot/gggrid_.py +126 -0
  63. lets_plot/plot/ggtb_.py +56 -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 +346 -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 +1336 -0
  76. lets_plot/plot/series_meta.py +129 -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 +766 -0
  81. lets_plot/plot/theme_set.py +393 -0
  82. lets_plot/plot/tooltip.py +486 -0
  83. lets_plot/plot/util.py +226 -0
  84. lets_plot/settings_utils.py +244 -0
  85. lets_plot/tilesets.py +364 -0
  86. lets_plot-4.6.0rc1.dist-info/LICENSE +21 -0
  87. lets_plot-4.6.0rc1.dist-info/METADATA +199 -0
  88. lets_plot-4.6.0rc1.dist-info/RECORD +91 -0
  89. lets_plot-4.6.0rc1.dist-info/WHEEL +5 -0
  90. lets_plot-4.6.0rc1.dist-info/top_level.txt +2 -0
  91. lets_plot_kotlin_bridge.cpython-312-darwin.so +0 -0
lets_plot/plot/plot.py ADDED
@@ -0,0 +1,244 @@
1
+ #
2
+ # Copyright (c) 2019. JetBrains s.r.o.
3
+ # Use of this source code is governed by the MIT license that can be found in the LICENSE file.
4
+ #
5
+ import numbers
6
+
7
+ from lets_plot._global_settings import has_global_value, get_global_val, MAX_WIDTH, MAX_HEIGHT
8
+ from lets_plot.geo_data_internals.utils import is_geocoder
9
+ from lets_plot.plot._global_theme import _get_global_theme
10
+ from lets_plot.plot.core import FeatureSpec
11
+ from lets_plot.plot.core import PlotSpec
12
+ from lets_plot.plot.util import as_annotated_data, key_int2str
13
+
14
+ __all__ = ['ggplot', 'ggsize', 'GGBunch']
15
+
16
+
17
+ def ggplot(data=None, mapping=None):
18
+ """
19
+ Create a new ggplot plot.
20
+
21
+ Parameters
22
+ ----------
23
+ data : dict or Pandas or Polars `DataFrame`
24
+ Default dataset to use for the plot. If not specified,
25
+ must be supplied in each layer added to the plot.
26
+ mapping : `FeatureSpec`
27
+ Default list of aesthetic mappings to use for the plot.
28
+ If not specified, must be supplied in each layer added to the plot.
29
+
30
+ Returns
31
+ -------
32
+ `PlotSpec`
33
+ Plot specification.
34
+
35
+ Notes
36
+ -----
37
+ `ggplot()` initializes a ggplot object.
38
+ It can be used to declare the input data frame for a graphic and
39
+ to specify the set of plot aesthetics intended to be common
40
+ throughout all subsequent layers unless specifically overridden.
41
+
42
+ `ggplot()` is typically used to construct a plot incrementally,
43
+ using the + operator to add layers to the existing ggplot object.
44
+ This is advantageous in that the code is explicit about which layers
45
+ are added and the order in which they are added. For complex graphics
46
+ with multiple layers, initialization with `ggplot()` is recommended.
47
+
48
+ There are three common ways to invoke ggplot (see examples below):
49
+
50
+ - `ggplot(data, aes(x, y))`: This method is recommended if all layers use the same data and the same set of aesthetics, although this method can also be used to add a layer using data from another data frame.
51
+ - `ggplot(data)`: This method specifies the default data frame to use for the plot, but no aesthetics are defined up front. This is useful when one data frame is used predominantly as layers are added, but the aesthetics may vary from one layer to another.
52
+ - `ggplot()`: This method initializes a skeleton ggplot object which is fleshed out as layers are added. This method is useful when multiple data frames are used to produce different layers, as is often the case in complex graphics.
53
+
54
+ `ggplot()` with no layers defined will produce an error message:
55
+ "No layers in plot".
56
+
57
+ Examples
58
+ --------
59
+ .. jupyter-execute::
60
+ :linenos:
61
+ :emphasize-lines: 11, 13, 15
62
+
63
+ import numpy as np
64
+ from lets_plot import *
65
+ LetsPlot.setup_html()
66
+ np.random.seed(42)
67
+ n = 100
68
+ x = np.random.uniform(-1, 1, size=n)
69
+ y = np.random.normal(size=n)
70
+ data = {'x': x, 'y': 25 * x ** 2 + y}
71
+ # three ways to invoke ggplot, producing the same output:
72
+ # (1)
73
+ ggplot(data, aes(x='x', y='y')) + geom_point()
74
+ # (2)
75
+ ggplot(data) + geom_point(aes(x='x', y='y'))
76
+ # (3)
77
+ ggplot() + geom_point(aes(x='x', y='y'), data=data)
78
+
79
+ """
80
+ if isinstance(data, FeatureSpec):
81
+ raise ValueError("Object {!r} is not acceptable as 'data' argument in ggplot()".format(data.kind))
82
+
83
+ if is_geocoder(data):
84
+ data = data.get_geocodes()
85
+
86
+ data = key_int2str(data)
87
+
88
+ data, mapping, data_meta = as_annotated_data(data, mapping)
89
+
90
+ plot_spec = PlotSpec(data, mapping, scales=[], layers=[], **data_meta)
91
+
92
+ if _get_global_theme() is not None:
93
+ plot_spec += _get_global_theme()
94
+
95
+ return plot_spec
96
+
97
+
98
+ # noinspection SpellCheckingInspection
99
+ def ggsize(width, height):
100
+ """
101
+ Specify overall size of plot.
102
+
103
+ Parameters
104
+ ----------
105
+ width : int
106
+ Width of plot in px.
107
+ height : int
108
+ Height of plot in px.
109
+
110
+ Returns
111
+ -------
112
+ `FeatureSpec`
113
+ Plot size specification.
114
+
115
+ Examples
116
+ --------
117
+ .. jupyter-execute::
118
+ :linenos:
119
+ :emphasize-lines: 8
120
+
121
+ import numpy as np
122
+ from lets_plot import *
123
+ LetsPlot.setup_html()
124
+ np.random.seed(42)
125
+ x = np.arange(50)
126
+ y = np.random.normal(size=50)
127
+ data = {'x': x, 'y': y}
128
+ ggplot(data) + geom_line(aes('x', 'y')) + ggsize(400, 150)
129
+
130
+ """
131
+ assert isinstance(width, numbers.Number), "'width' must be numeric"
132
+ assert isinstance(height, numbers.Number), "'height' must be numeric"
133
+
134
+ max_width = get_global_val(MAX_WIDTH) if has_global_value(MAX_WIDTH) else 10_000
135
+ max_height = get_global_val(MAX_HEIGHT) if has_global_value(MAX_HEIGHT) else 10_000
136
+
137
+ assert width <= max_width, "'width' must be less than or equal to " + str(max_width)
138
+ assert height <= max_height, "'height' must be less than or equal to " + str(max_height)
139
+
140
+ return FeatureSpec('ggsize', name=None, width=width, height=height)
141
+
142
+
143
+ class GGBunch(FeatureSpec):
144
+ """
145
+ Class `GGBunch` is deprecated and will be removed in future releases.
146
+ Please, use function `ggbunch()` to combine several plots into a single figure with custom layout.
147
+
148
+ Collection of plots created by ggplot function.
149
+ Use method `add_plot()` to add plot to 'bunch'.
150
+ Each plot can have arbitrary location and size.
151
+ Use `show()` to draw all plots in bunch.
152
+
153
+ Examples
154
+ --------
155
+ .. jupyter-execute::
156
+ :linenos:
157
+ :emphasize-lines: 10-14
158
+
159
+ import numpy as np
160
+ from lets_plot import *
161
+ LetsPlot.setup_html()
162
+ np.random.seed(42)
163
+ n = 100
164
+ x = np.arange(n)
165
+ y = np.random.normal(size=n)
166
+ w, h = 200, 150
167
+ p = ggplot({'x': x, 'y': y}, aes(x='x', y='y')) + ggsize(w, h)
168
+ bunch = GGBunch()
169
+ bunch.add_plot(p + geom_point(), 0, 0)
170
+ bunch.add_plot(p + geom_histogram(bins=3), w, 0)
171
+ bunch.add_plot(p + geom_line(), 0, h, 2*w, h)
172
+ bunch.show()
173
+
174
+ """
175
+
176
+ def __init__(self):
177
+ """
178
+ Initialize self.
179
+ """
180
+ super().__init__('ggbunch', None)
181
+ self.items = []
182
+ print("\n(!) WARN: class GGBunch is deprecated and will be removed in future releases.\n\n"
183
+ " Please, use function ggbunch() to combine several plots into\n"
184
+ " a single figure with custom layout.\n")
185
+
186
+
187
+ def add_plot(self, plot_spec: PlotSpec, x, y, width=None, height=None):
188
+ """
189
+ Add plot to 'bunch'.
190
+
191
+ Parameters
192
+ ----------
193
+ plot_spec
194
+ Plot specification created by `ggplot()` function.
195
+ x : int
196
+ x-coordinate of plot origin in px.
197
+ y : int
198
+ y-coordinate of plot origin in px.
199
+ width : int
200
+ Width of plot in px.
201
+ height : int
202
+ Height of plot in px.
203
+
204
+ """
205
+ if width and not height:
206
+ raise TypeError('height argument is required')
207
+ if height and not width:
208
+ raise TypeError('width argument is required')
209
+
210
+ assert isinstance(x, numbers.Number), "'x' must be numeric"
211
+ assert isinstance(y, numbers.Number), "'y' must be numeric"
212
+ if width:
213
+ assert isinstance(width, numbers.Number), "'width' must be numeric"
214
+ if height:
215
+ assert isinstance(height, numbers.Number), "'height' must be numeric"
216
+
217
+ self.items.append(dict(feature_spec=plot_spec, x=x, y=y, width=width, height=height))
218
+
219
+ def as_dict(self):
220
+ d = super().as_dict()
221
+ d['kind'] = self.kind
222
+
223
+ def item_as_dict(item):
224
+ result = dict((k, v) for k, v in item.items() if k != 'feature_spec')
225
+ result['feature_spec'] = item['feature_spec'].as_dict()
226
+ return result
227
+
228
+ d['items'] = [item_as_dict(item) for item in self.items]
229
+ return d
230
+
231
+ def _repr_html_(self):
232
+ """
233
+ Special method discovered and invoked by IPython.display.display.
234
+ """
235
+ from ..frontend_context._configuration import _as_html
236
+ return _as_html(self.as_dict())
237
+
238
+ def show(self):
239
+ """
240
+ Draw all plots currently in this 'bunch'.
241
+ """
242
+ from ..frontend_context._configuration import _display_plot
243
+ _display_plot(self)
244
+
lets_plot/plot/pos.py ADDED
@@ -0,0 +1,346 @@
1
+ #
2
+ # Copyright (c) 2019. JetBrains s.r.o.
3
+ # Use of this source code is governed by the MIT license that can be found in the LICENSE file.
4
+ #
5
+ from .core import FeatureSpec
6
+
7
+ #
8
+ # Position Adjustments
9
+ #
10
+ __all__ = ['position_dodge', 'position_dodgev', 'position_jitter', 'position_nudge', 'position_jitterdodge',
11
+ 'position_stack', 'position_fill']
12
+
13
+
14
+ def position_dodge(width=None):
15
+ """
16
+ Adjust position by dodging overlaps to the side.
17
+
18
+ Parameters
19
+ ----------
20
+ width : float
21
+ Dodging width, when different to the width of the individual elements.
22
+ This is useful when you want to align narrow geoms with wider geoms.
23
+ The value of width is relative and typically ranges between 0 and 1.
24
+ Values that are greater than 1 lead to overlapping of the objects.
25
+
26
+ Returns
27
+ -------
28
+ `FeatureSpec`
29
+ Geom object position specification.
30
+
31
+ Notes
32
+ -----
33
+ Adjust position by dodging overlaps to the side.
34
+
35
+ Examples
36
+ --------
37
+ .. jupyter-execute::
38
+ :linenos:
39
+ :emphasize-lines: 10
40
+
41
+ import numpy as np
42
+ from lets_plot import *
43
+ LetsPlot.setup_html()
44
+ n = 100
45
+ np.random.seed(42)
46
+ x = np.random.randint(5, size=n)
47
+ c = np.random.choice(['a', 'b', 'c'], size=n)
48
+ ggplot({'x': x, 'c': c}, aes(x='x')) + \\
49
+ geom_bar(aes(fill='c'), width=.4, \\
50
+ position=position_dodge(width=.6))
51
+
52
+ """
53
+ return _pos('dodge', width=width)
54
+
55
+
56
+ def position_dodgev(height=None):
57
+ """
58
+ Adjust position by dodging overlaps to the side.
59
+
60
+ Parameters
61
+ ----------
62
+ height : float
63
+ Dodging height, when different to the height of the individual elements.
64
+ This is useful when you want to align narrow geoms with taller geoms.
65
+ The value of height is relative and typically ranges between 0 and 1.
66
+ Values that are greater than 1 lead to overlapping of the objects.
67
+
68
+ Returns
69
+ -------
70
+ `FeatureSpec`
71
+ Geom object position specification.
72
+
73
+ Notes
74
+ -----
75
+ Adjust position by dodging overlaps to the side.
76
+
77
+ Examples
78
+ --------
79
+ .. jupyter-execute::
80
+ :linenos:
81
+ :emphasize-lines: 11
82
+
83
+ from lets_plot import *
84
+ LetsPlot.setup_html()
85
+ data = {
86
+ 'xmin': [0.2, 4.6, 1.6, 3.5],
87
+ 'xmax': [1.5, 5.3, 3.0, 4.4],
88
+ 'y': ['a', 'a', 'b', 'b'],
89
+ 'c': ['gr1', 'gr2', 'gr1', 'gr2']
90
+ }
91
+ ggplot(data, aes(y='y', color='c')) + \\
92
+ geom_errorbar(aes(xmin='xmin', xmax='xmax'), height=0.1, size=2, \\
93
+ position=position_dodgev(height=0.2))
94
+
95
+ """
96
+ return _pos('dodgev', height=height)
97
+
98
+
99
+ def position_jitter(width=None, height=None, seed=None):
100
+ """
101
+ Adjust position by assigning random noise to points. Better for discrete values.
102
+
103
+ Parameters
104
+ ----------
105
+ width : float
106
+ Jittering width.
107
+ The value of width is relative and typically ranges between 0 and 0.5.
108
+ Values that are greater than 0.5 lead to overlapping of the points.
109
+ height : float
110
+ Jittering height.
111
+ The value of height is relative and typically ranges between 0 and 0.5.
112
+ Values that are greater than 0.5 lead to overlapping of the points.
113
+ seed : int
114
+ A random seed to make the jitter reproducible.
115
+ If None (the default value), the seed is initialised with a random value.
116
+
117
+ Returns
118
+ -------
119
+ `FeatureSpec`
120
+ Geom object position specification.
121
+
122
+ Notes
123
+ -----
124
+ Adjust position by dodging overlaps to the side.
125
+
126
+ Examples
127
+ --------
128
+ .. jupyter-execute::
129
+ :linenos:
130
+ :emphasize-lines: 12
131
+
132
+ import numpy as np
133
+ from lets_plot import *
134
+ LetsPlot.setup_html()
135
+ n = 100
136
+ np.random.seed(42)
137
+ x = np.random.randint(4, size=n)
138
+ y = np.random.randint(3, size=n)
139
+ c = np.char.add(x.astype(str), y.astype(str))
140
+ ggplot({'x': x, 'y': y, 'c': c}, aes('x', 'y')) + \\
141
+ geom_point(aes(fill='c'), show_legend=False, \\
142
+ size=8, alpha=.5, shape=21, color='black', \\
143
+ position=position_jitter(width=.2, height=.2, seed=42))
144
+
145
+ """
146
+ return _pos('jitter', width=width, height=height, seed=seed)
147
+
148
+
149
+ def position_nudge(x=None, y=None, unit=None):
150
+ """
151
+ Adjust position by nudging a given offset.
152
+
153
+ Parameters
154
+ ----------
155
+ x : float
156
+ Nudging width.
157
+ y : float
158
+ Nudging height.
159
+ unit : {'identity', 'size', 'px'}
160
+ Units for x and y nudging.
161
+
162
+ Returns
163
+ -------
164
+ `FeatureSpec`
165
+ Geom object position specification.
166
+
167
+ Notes
168
+ -----
169
+ Adjust position by dodging overlaps to the side.
170
+
171
+ Examples
172
+ --------
173
+ .. jupyter-execute::
174
+ :linenos:
175
+ :emphasize-lines: 11
176
+
177
+ import numpy as np
178
+ from lets_plot import *
179
+ LetsPlot.setup_html()
180
+ n = 5
181
+ np.random.seed(42)
182
+ x = np.random.uniform(size=n)
183
+ y = np.random.uniform(size=n)
184
+ t = np.random.choice(list('abcdefghijk'), size=n)
185
+ ggplot({'x': x, 'y': y, 't': t}, aes('x', 'y')) + \\
186
+ geom_point(size=5, shape=21, color='black', fill='red') + \\
187
+ geom_text(aes(label='t'), position=position_nudge(y=.05, unit='identity'))
188
+
189
+ """
190
+ return _pos('nudge', x=x, y=y, unit=unit)
191
+
192
+
193
+ def position_jitterdodge(dodge_width=None, jitter_width=None, jitter_height=None, seed=None):
194
+ """
195
+ This is primarily used for aligning points generated through `geom_point()`
196
+ with dodged boxplots (e.g., a `geom_boxplot()` with a fill aesthetic supplied).
197
+
198
+ Parameters
199
+ ----------
200
+ dodge_width : float
201
+ Bin width.
202
+ The value of `dodge_width` is relative and typically ranges between 0 and 1.
203
+ Values that are greater than 1 lead to overlapping of the boxes.
204
+ jitter_width : float
205
+ Jittering width.
206
+ The value of `jitter_width` is relative and typically ranges between 0 and 0.5.
207
+ Values that are greater than 0.5 lead to overlapping of the points.
208
+ jitter_height : float
209
+ Jittering height.
210
+ The value of `jitter_height` is relative and typically ranges between 0 and 0.5.
211
+ Values that are greater than 0.5 lead to overlapping of the points.
212
+ seed : int
213
+ A random seed to make the jitter reproducible.
214
+ If None (the default value), the seed is initialised with a random value.
215
+
216
+ Returns
217
+ -------
218
+ `FeatureSpec`
219
+ Geom object position specification.
220
+
221
+ Notes
222
+ -----
223
+ Adjust position by dodging overlaps to the side.
224
+
225
+ Examples
226
+ --------
227
+ .. jupyter-execute::
228
+ :linenos:
229
+ :emphasize-lines: 13
230
+
231
+ import numpy as np
232
+ from lets_plot import *
233
+ LetsPlot.setup_html()
234
+ n = 50
235
+ np.random.seed(42)
236
+ x = np.random.uniform(size=n)
237
+ c = np.random.choice(['a', 'b', 'c'], size=n)
238
+ ggplot({'x': x, 'c': c}) + \\
239
+ geom_crossbar(aes(x='c', y='x', color='c'), \\
240
+ stat='boxplot') + \\
241
+ geom_point(aes(x='c', y='x', color='c'), \\
242
+ size=4, shape=21, fill='white',
243
+ position=position_jitterdodge(seed=42))
244
+
245
+ """
246
+ return _pos('jitterdodge', dodge_width=dodge_width, jitter_width=jitter_width, jitter_height=jitter_height,
247
+ seed=seed)
248
+
249
+
250
+ def position_stack(vjust=None, mode=None):
251
+ """
252
+ Adjust position by stacking overlapping objects on top of each other.
253
+ Preferred for density-like geometries.
254
+
255
+ Parameters
256
+ ----------
257
+ vjust : float
258
+ Vertical adjustment for geoms that have a position (like points or lines),
259
+ not a dimension (like bars or areas).
260
+ Set to 0 to align with the bottom, 0.5 for the middle, and 1 for the top.
261
+ mode : {'groups', 'all'}, default='groups'
262
+ If 'groups', objects inside one group are positioned as in `position='identity'`,
263
+ but each group is shifted to sum of heights of previous groups
264
+ (where height of a group is a maximum of it's y values).
265
+ If 'all', each object will be shifted.
266
+
267
+ Returns
268
+ -------
269
+ `FeatureSpec`
270
+ Geom object position specification.
271
+
272
+ Notes
273
+ -----
274
+ Adjust position by stacking overlapping objects on top of each other.
275
+
276
+ Examples
277
+ --------
278
+ .. jupyter-execute::
279
+ :linenos:
280
+ :emphasize-lines: 9
281
+
282
+ from lets_plot import *
283
+ LetsPlot.setup_html()
284
+ data = {
285
+ 'x': [1, 1, 1, 2, 2, 2],
286
+ 'y': [1, 2, 3, 1, 2, 3],
287
+ 'g': ["a", "b", "b", "a", "a", "b"],
288
+ }
289
+ ggplot(data, aes('x', 'y', color='g')) + \\
290
+ geom_point(position=position_stack(), size=10)
291
+
292
+ """
293
+ return _pos('stack', vjust=vjust, mode=mode)
294
+
295
+
296
+ def position_fill(vjust=None, mode=None):
297
+ """
298
+ Adjust position by stacking overlapping objects on top of each other
299
+ and standardise each stack to have constant height.
300
+
301
+ Parameters
302
+ ----------
303
+ vjust : float
304
+ Vertical adjustment for geoms that have a position (like points or lines),
305
+ not a dimension (like bars or areas).
306
+ Set to 0 to align with the bottom, 0.5 for the middle, and 1 for the top.
307
+ mode : {'groups', 'all'}, default='groups'
308
+ If 'groups', objects inside one group are positioned as in `position='identity'`,
309
+ but each group is shifted to sum of heights of previous groups
310
+ (where height of a group is a maximum of it's y values).
311
+ If 'all', each object will be shifted.
312
+
313
+ Returns
314
+ -------
315
+ `FeatureSpec`
316
+ Geom object position specification.
317
+
318
+ Notes
319
+ -----
320
+ Adjust position by stacking overlapping objects on top of each other
321
+ and standardise each stack to have constant height.
322
+
323
+ Examples
324
+ --------
325
+ .. jupyter-execute::
326
+ :linenos:
327
+ :emphasize-lines: 9
328
+
329
+ from lets_plot import *
330
+ LetsPlot.setup_html()
331
+ data = {
332
+ 'x': [1, 1, 1, 1, 1, 2, 2, 2],
333
+ 'y': [1, 2, 3, 4, 5, 1, 2, 3],
334
+ 'g': ["a", "a", "b", "b", "b", "a", "a", "b"],
335
+ }
336
+ ggplot(data, aes('x', 'y', color='g')) + \\
337
+ geom_point(position=position_fill(), size=10)
338
+
339
+ """
340
+ return _pos('fill', vjust=vjust, mode=mode)
341
+
342
+
343
+ def _pos(name, **other):
344
+ args = locals().copy()
345
+ args.pop('other')
346
+ return FeatureSpec('pos', **args, **other)