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
|
@@ -0,0 +1,64 @@
|
|
|
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 .annotation import *
|
|
6
|
+
from .coord import *
|
|
7
|
+
from .core import *
|
|
8
|
+
from .expand_limits_ import *
|
|
9
|
+
from .facet import *
|
|
10
|
+
from .font_features import *
|
|
11
|
+
from .geom import *
|
|
12
|
+
from .geom_extras import *
|
|
13
|
+
from .geom_function_ import *
|
|
14
|
+
from .geom_imshow_ import *
|
|
15
|
+
from .geom_livemap_ import *
|
|
16
|
+
from .ggbunch_ import *
|
|
17
|
+
from .gggrid_ import *
|
|
18
|
+
from .ggtb_ import *
|
|
19
|
+
from .guide import *
|
|
20
|
+
from .label import *
|
|
21
|
+
from .marginal_layer import *
|
|
22
|
+
from .plot import *
|
|
23
|
+
from .pos import *
|
|
24
|
+
from .sampling import *
|
|
25
|
+
from .scale import *
|
|
26
|
+
from .scale_colormap_mpl import *
|
|
27
|
+
from .scale_convenience import *
|
|
28
|
+
from .scale_identity_ import *
|
|
29
|
+
from .scale_position import *
|
|
30
|
+
from .stat import *
|
|
31
|
+
from .theme_ import *
|
|
32
|
+
from .theme_set import *
|
|
33
|
+
from .tooltip import *
|
|
34
|
+
|
|
35
|
+
__all__ = (coord.__all__ +
|
|
36
|
+
core.__all__ +
|
|
37
|
+
facet.__all__ +
|
|
38
|
+
geom.__all__ +
|
|
39
|
+
geom_extras.__all__ +
|
|
40
|
+
geom_function_.__all__ +
|
|
41
|
+
geom_imshow_.__all__ +
|
|
42
|
+
geom_livemap_.__all__ +
|
|
43
|
+
guide.__all__ +
|
|
44
|
+
label.__all__ +
|
|
45
|
+
plot.__all__ +
|
|
46
|
+
pos.__all__ +
|
|
47
|
+
sampling.__all__ +
|
|
48
|
+
scale.__all__ +
|
|
49
|
+
scale_colormap_mpl.__all__ +
|
|
50
|
+
scale_convenience.__all__ +
|
|
51
|
+
scale_identity_.__all__ +
|
|
52
|
+
scale_position.__all__ +
|
|
53
|
+
stat.__all__ +
|
|
54
|
+
theme_.__all__ +
|
|
55
|
+
theme_set.__all__ +
|
|
56
|
+
tooltip.__all__ +
|
|
57
|
+
annotation.__all__ +
|
|
58
|
+
marginal_layer.__all__ +
|
|
59
|
+
font_features.__all__ +
|
|
60
|
+
ggbunch_.__all__ +
|
|
61
|
+
gggrid_.__all__ +
|
|
62
|
+
ggtb_.__all__ +
|
|
63
|
+
expand_limits_.__all__
|
|
64
|
+
)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright (c) 2024. 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
|
+
_global_theme = None
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def _set_global_theme(theme):
|
|
9
|
+
global _global_theme
|
|
10
|
+
_global_theme = theme
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def _get_global_theme():
|
|
14
|
+
return _global_theme
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
# Copyright (c) 2022. 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
|
+
|
|
4
|
+
from typing import List
|
|
5
|
+
|
|
6
|
+
from lets_plot.plot.core import FeatureSpec, _filter_none
|
|
7
|
+
|
|
8
|
+
#
|
|
9
|
+
# Annotations
|
|
10
|
+
#
|
|
11
|
+
|
|
12
|
+
__all__ = ['layer_labels']
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class layer_labels(FeatureSpec):
|
|
16
|
+
"""
|
|
17
|
+
Configure annotations for geometry layers.
|
|
18
|
+
|
|
19
|
+
Annotations are currently supported for bar, pie, and crossbar geometry
|
|
20
|
+
layers. This class provides methods to customize the appearance and
|
|
21
|
+
content of text labels displayed on these geometries.
|
|
22
|
+
|
|
23
|
+
Notes
|
|
24
|
+
-----
|
|
25
|
+
By default, annotation text color is automatically selected for optimal
|
|
26
|
+
contrast: white text appears on darker filled geometries, and black text
|
|
27
|
+
appears on lighter filled geometries.
|
|
28
|
+
|
|
29
|
+
The text color can be manually specified using:
|
|
30
|
+
``theme(label_text=element_text(color=...))``
|
|
31
|
+
|
|
32
|
+
Alternatively, the ``inherit_color()`` method can be used to override both
|
|
33
|
+
automatic and manual color settings, making the annotation text use the
|
|
34
|
+
geometry's ``color`` aesthetic instead.
|
|
35
|
+
|
|
36
|
+
Examples
|
|
37
|
+
--------
|
|
38
|
+
.. jupyter-execute::
|
|
39
|
+
:linenos:
|
|
40
|
+
:emphasize-lines: 6
|
|
41
|
+
|
|
42
|
+
from lets_plot import *
|
|
43
|
+
LetsPlot.setup_html()
|
|
44
|
+
data = {'name': ['a', 'b', 'c', 'd', 'b'], 'value': [40, 90, 10, 50, 20 ]}
|
|
45
|
+
ggplot(data) + geom_pie(aes(slice='value', fill='name'), size=15, hole=0.4, \\
|
|
46
|
+
stat='identity', tooltips='none', \\
|
|
47
|
+
labels=layer_labels().line('@value'))
|
|
48
|
+
|
|
49
|
+
"""
|
|
50
|
+
|
|
51
|
+
def __init__(self, variables: List[str] = None):
|
|
52
|
+
"""
|
|
53
|
+
Initialize self.
|
|
54
|
+
|
|
55
|
+
Parameters
|
|
56
|
+
----------
|
|
57
|
+
variables : list of str
|
|
58
|
+
Variable names to place in the annotation with default formatting.
|
|
59
|
+
|
|
60
|
+
"""
|
|
61
|
+
|
|
62
|
+
self._formats: List = []
|
|
63
|
+
self._lines: List = None
|
|
64
|
+
self._variables = variables
|
|
65
|
+
self._size = None
|
|
66
|
+
self._useLayerColor = None
|
|
67
|
+
super().__init__('labels', name=None)
|
|
68
|
+
|
|
69
|
+
def as_dict(self):
|
|
70
|
+
"""
|
|
71
|
+
Return a dictionary of all properties of the object.
|
|
72
|
+
|
|
73
|
+
Returns
|
|
74
|
+
-------
|
|
75
|
+
dict
|
|
76
|
+
Dictionary of properties.
|
|
77
|
+
|
|
78
|
+
Examples
|
|
79
|
+
--------
|
|
80
|
+
.. jupyter-execute::
|
|
81
|
+
:linenos:
|
|
82
|
+
:emphasize-lines: 6
|
|
83
|
+
|
|
84
|
+
from lets_plot import *
|
|
85
|
+
LetsPlot.setup_html()
|
|
86
|
+
layer_labels().format('@{..prop..}', '.0%') \\
|
|
87
|
+
.line('@name') \\
|
|
88
|
+
.line('(@{..prop..})') \\
|
|
89
|
+
.as_dict()
|
|
90
|
+
|
|
91
|
+
"""
|
|
92
|
+
d = super().as_dict()
|
|
93
|
+
d['formats'] = self._formats
|
|
94
|
+
d['lines'] = self._lines
|
|
95
|
+
d['variables'] = self._variables
|
|
96
|
+
d['annotation_size'] = self._size
|
|
97
|
+
d['use_layer_color'] = self._useLayerColor
|
|
98
|
+
return _filter_none(d)
|
|
99
|
+
|
|
100
|
+
def format(self, field=None, format=None):
|
|
101
|
+
"""
|
|
102
|
+
Define the format for displaying the value.
|
|
103
|
+
This format will be applied to the corresponding value specified in the 'line' template.
|
|
104
|
+
|
|
105
|
+
Parameters
|
|
106
|
+
----------
|
|
107
|
+
field : str
|
|
108
|
+
Name of an aesthetic or variable that would be formatted.
|
|
109
|
+
The field name starts with a '^' prefix for aesthetics,
|
|
110
|
+
the variable name starts with a '@' prefix or without any prefix.
|
|
111
|
+
format : str
|
|
112
|
+
Formatting specification. The format contains a number format ('1.f'),
|
|
113
|
+
a string template ('{.1f}') or a date/time format ('%d.%m.%y').
|
|
114
|
+
The numeric format for non-numeric value will be ignored.
|
|
115
|
+
If you need to include a brace character in the literal text,
|
|
116
|
+
it can be escaped by doubling: ``{{`` and ``}}``.
|
|
117
|
+
|
|
118
|
+
Returns
|
|
119
|
+
-------
|
|
120
|
+
``layer_labels``
|
|
121
|
+
Annotations specification.
|
|
122
|
+
|
|
123
|
+
Notes
|
|
124
|
+
-----
|
|
125
|
+
For more info see `Formatting <https://lets-plot.org/python/pages/formats.html>`__.
|
|
126
|
+
|
|
127
|
+
Examples
|
|
128
|
+
--------
|
|
129
|
+
.. jupyter-execute::
|
|
130
|
+
:linenos:
|
|
131
|
+
:emphasize-lines: 7
|
|
132
|
+
|
|
133
|
+
from lets_plot import *
|
|
134
|
+
LetsPlot.setup_html()
|
|
135
|
+
data = {'name': ['a', 'b', 'c', 'd', 'b'], 'value': [40, 90, 10, 50, 20 ]}
|
|
136
|
+
ggplot(data) + geom_pie(aes(fill=as_discrete('name', order_by='..count..'), weight='value'), \\
|
|
137
|
+
size=15, tooltips='none', \\
|
|
138
|
+
labels=layer_labels(['..proppct..']) \\
|
|
139
|
+
.format('..proppct..', '{.1f}%'))
|
|
140
|
+
|
|
141
|
+
|
|
|
142
|
+
|
|
143
|
+
.. jupyter-execute::
|
|
144
|
+
:linenos:
|
|
145
|
+
:emphasize-lines: 7, 9, 11, 13
|
|
146
|
+
|
|
147
|
+
from lets_plot import *
|
|
148
|
+
LetsPlot.setup_html()
|
|
149
|
+
data = {'name': ['a', 'b', 'c', 'd', 'b'], 'value': [40, 90, 10, 50, 20 ]}
|
|
150
|
+
ggplot(data) + geom_pie(aes(fill=as_discrete('name', order_by='..count..', order=1), weight='value'), \\
|
|
151
|
+
size=15, tooltips='none', \\
|
|
152
|
+
labels=layer_labels() \\
|
|
153
|
+
.format('^fill', '{{{}}}') \\
|
|
154
|
+
.line('^fill') \\
|
|
155
|
+
.format('..count..', 'd') \\
|
|
156
|
+
.line('@{..count..}') \\
|
|
157
|
+
.format('..prop..', '.1%') \\
|
|
158
|
+
.line('@{..prop..}') \\
|
|
159
|
+
.format('..sum..', 'of {d}') \\
|
|
160
|
+
.line('@{..sum..}'))
|
|
161
|
+
|
|
162
|
+
"""
|
|
163
|
+
self._formats.append({"field": field, "format": format})
|
|
164
|
+
return self
|
|
165
|
+
|
|
166
|
+
def line(self, value):
|
|
167
|
+
"""
|
|
168
|
+
Add a line of text to the multiline label annotation.
|
|
169
|
+
|
|
170
|
+
This method configures one line of text that will be displayed in a
|
|
171
|
+
multiline label. Multiple calls to this method can be chained to build
|
|
172
|
+
up a complete multiline annotation.
|
|
173
|
+
|
|
174
|
+
Parameters
|
|
175
|
+
----------
|
|
176
|
+
value : str
|
|
177
|
+
The text content for this line of the annotation. Can include
|
|
178
|
+
variable and aesthetic references.
|
|
179
|
+
|
|
180
|
+
Returns
|
|
181
|
+
-------
|
|
182
|
+
``layer_labels``
|
|
183
|
+
Annotations specification.
|
|
184
|
+
|
|
185
|
+
Notes
|
|
186
|
+
-----
|
|
187
|
+
Variables and aesthetics can be accessed via special syntax:
|
|
188
|
+
|
|
189
|
+
- ^color for aesthetics,
|
|
190
|
+
- @x for variable,
|
|
191
|
+
- @{x + 1} for variable with spaces in the name,
|
|
192
|
+
- @{x^2 + 1} for variable with spaces and '^' symbol in the name,
|
|
193
|
+
- @x^2 for variable with '^' symbol in its name.
|
|
194
|
+
|
|
195
|
+
Special characters can be escaped:
|
|
196
|
+
|
|
197
|
+
- 'x\\\\^2' -> "x^2" (escape ^ with backslash)
|
|
198
|
+
- '{{x}}' -> "{x}" (escape braces by doubling)
|
|
199
|
+
|
|
200
|
+
Examples
|
|
201
|
+
--------
|
|
202
|
+
.. jupyter-execute::
|
|
203
|
+
:linenos:
|
|
204
|
+
:emphasize-lines: 8-11
|
|
205
|
+
|
|
206
|
+
from lets_plot import *
|
|
207
|
+
LetsPlot.setup_html()
|
|
208
|
+
data = {'name': ['a', 'b', 'c', 'd', 'b'], 'value': [40, 90, 10, 50, 20 ]}
|
|
209
|
+
ggplot(data) + geom_pie(aes(fill='name', weight='value'), size=15, \\
|
|
210
|
+
tooltips='none', \\
|
|
211
|
+
labels=layer_labels()\\
|
|
212
|
+
.format('..prop..', '.1%')\\
|
|
213
|
+
.line('"^fill"')\\
|
|
214
|
+
.line('@{..count..}')\\
|
|
215
|
+
.line('@{..prop..}')\\
|
|
216
|
+
.line('(@{..sum..})'))
|
|
217
|
+
|
|
218
|
+
"""
|
|
219
|
+
if self._lines is None:
|
|
220
|
+
self._lines = []
|
|
221
|
+
self._lines.append(value)
|
|
222
|
+
return self
|
|
223
|
+
|
|
224
|
+
def size(self, value):
|
|
225
|
+
"""
|
|
226
|
+
Set the text size for the annotation.
|
|
227
|
+
|
|
228
|
+
Parameters
|
|
229
|
+
----------
|
|
230
|
+
value : float
|
|
231
|
+
The text size value for the annotation.
|
|
232
|
+
|
|
233
|
+
Returns
|
|
234
|
+
-------
|
|
235
|
+
``layer_labels``
|
|
236
|
+
Annotations specification.
|
|
237
|
+
|
|
238
|
+
Examples
|
|
239
|
+
--------
|
|
240
|
+
|
|
241
|
+
.. jupyter-execute::
|
|
242
|
+
:linenos:
|
|
243
|
+
:emphasize-lines: 7
|
|
244
|
+
|
|
245
|
+
from lets_plot import *
|
|
246
|
+
LetsPlot.setup_html()
|
|
247
|
+
data = {'name': ['a', 'b', 'c', 'd', 'b'], 'value': [40, 90, 10, 50, 20 ]}
|
|
248
|
+
ggplot(data) + geom_pie(aes(slice='value', fill='name'), size=15, hole=0.4, \\
|
|
249
|
+
stat='identity', tooltips='none', \\
|
|
250
|
+
labels=layer_labels().line('@value')
|
|
251
|
+
.size(25))
|
|
252
|
+
|
|
253
|
+
"""
|
|
254
|
+
|
|
255
|
+
self._size = value
|
|
256
|
+
return self
|
|
257
|
+
|
|
258
|
+
def inherit_color(self):
|
|
259
|
+
"""
|
|
260
|
+
Use the layer's color for the annotation text.
|
|
261
|
+
|
|
262
|
+
When enabled, the annotation text will inherit the color from the
|
|
263
|
+
layer it's associated with, rather than using a default or
|
|
264
|
+
explicitly set color.
|
|
265
|
+
|
|
266
|
+
Returns
|
|
267
|
+
-------
|
|
268
|
+
``layer_labels``
|
|
269
|
+
Annotations specification.
|
|
270
|
+
|
|
271
|
+
Examples
|
|
272
|
+
--------
|
|
273
|
+
|
|
274
|
+
.. jupyter-execute::
|
|
275
|
+
:linenos:
|
|
276
|
+
:emphasize-lines: 8
|
|
277
|
+
|
|
278
|
+
from lets_plot import *
|
|
279
|
+
LetsPlot.setup_html()
|
|
280
|
+
data = {'name': ['a', 'b', 'c', 'd', 'b'], 'value': [40, 90, 10, 50, 20 ]}
|
|
281
|
+
ggplot(data) + geom_pie(aes(slice='value', color='name'), alpha=0, size=15, hole=0.4, \\
|
|
282
|
+
stroke=5, spacer_color='pen', \\
|
|
283
|
+
stat='identity', tooltips='none', \\
|
|
284
|
+
labels=layer_labels().line('@value')
|
|
285
|
+
.inherit_color())
|
|
286
|
+
|
|
287
|
+
"""
|
|
288
|
+
|
|
289
|
+
self._useLayerColor = True
|
|
290
|
+
return self
|
lets_plot/plot/coord.py
ADDED
|
@@ -0,0 +1,242 @@
|
|
|
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
|
+
# Coordinate Systems
|
|
9
|
+
#
|
|
10
|
+
__all__ = ['coord_cartesian',
|
|
11
|
+
'coord_fixed',
|
|
12
|
+
'coord_map',
|
|
13
|
+
'coord_flip',
|
|
14
|
+
'coord_polar',
|
|
15
|
+
]
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def coord_cartesian(xlim=None, ylim=None, flip=False):
|
|
19
|
+
"""
|
|
20
|
+
The Cartesian coordinate system is the most familiar and common type of coordinate system.
|
|
21
|
+
Setting limits on the coordinate system will zoom the plot like you're looking at it with a magnifying glass.
|
|
22
|
+
It does not change the underlying data as setting limits on a scale does.
|
|
23
|
+
|
|
24
|
+
Parameters
|
|
25
|
+
----------
|
|
26
|
+
xlim : list
|
|
27
|
+
Limits (2 elements) for the x axis.
|
|
28
|
+
1st element defines lower limit, 2nd element defines upper limit.
|
|
29
|
+
None means no lower / upper bound - depending on the index in list.
|
|
30
|
+
ylim : list
|
|
31
|
+
Limits (2 elements) for the y axis.
|
|
32
|
+
1st element defines lower limit, 2nd element defines upper limit.
|
|
33
|
+
None means no lower / upper bound - depending on the index in list.
|
|
34
|
+
flip : bool
|
|
35
|
+
Flip the coordinate system axis so that horizontal axis becomes vertical and vice versa.
|
|
36
|
+
|
|
37
|
+
Returns
|
|
38
|
+
-------
|
|
39
|
+
``FeatureSpec``
|
|
40
|
+
Coordinate system specification.
|
|
41
|
+
|
|
42
|
+
Examples
|
|
43
|
+
--------
|
|
44
|
+
.. jupyter-execute::
|
|
45
|
+
:linenos:
|
|
46
|
+
:emphasize-lines: 7
|
|
47
|
+
|
|
48
|
+
from lets_plot import *
|
|
49
|
+
LetsPlot.setup_html()
|
|
50
|
+
data = {'x': [0, 8, 12, 17, 20, 26],
|
|
51
|
+
'y': [0, 8, 12, 17, 20, 26],
|
|
52
|
+
'g': ['a', 'a', 'b', 'b', 'c', 'c']}
|
|
53
|
+
ggplot(data) + geom_line(aes(x='x', y='y', group='g')) + \\
|
|
54
|
+
coord_cartesian(xlim=(4, 23), ylim=(3, 22))
|
|
55
|
+
|
|
56
|
+
"""
|
|
57
|
+
|
|
58
|
+
return _coord('cartesian', xlim=xlim, ylim=ylim, flip=flip)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def coord_fixed(ratio=1., xlim=None, ylim=None, flip=False):
|
|
62
|
+
"""
|
|
63
|
+
A fixed scale coordinate system forces a specified ratio between the physical representations of data units on the axes.
|
|
64
|
+
|
|
65
|
+
Parameters
|
|
66
|
+
----------
|
|
67
|
+
ratio : float
|
|
68
|
+
The ratio represents the number of units on the y-axis equivalent to one unit on the x-axis.
|
|
69
|
+
ratio = 1, ensures that one unit on the x-axis is the same length as one unit on the y-axis.
|
|
70
|
+
Ratios higher than one make units on the y-axis longer than units on the x-axis, and vice versa.
|
|
71
|
+
xlim : list
|
|
72
|
+
Limits (2 elements) for the x axis.
|
|
73
|
+
1st element defines lower limit, 2nd element defines upper limit.
|
|
74
|
+
None means no lower / upper bound - depending on the index in list.
|
|
75
|
+
ylim : list
|
|
76
|
+
Limits (2 elements) for the y axis.
|
|
77
|
+
1st element defines lower limit, 2nd element defines upper limit.
|
|
78
|
+
None means no lower / upper bound - depending on the index in list.
|
|
79
|
+
flip : bool
|
|
80
|
+
Flip the coordinate system axis so that horizontal axis becomes vertical and vice versa.
|
|
81
|
+
|
|
82
|
+
Returns
|
|
83
|
+
-------
|
|
84
|
+
``FeatureSpec``
|
|
85
|
+
Coordinate system specification.
|
|
86
|
+
|
|
87
|
+
Examples
|
|
88
|
+
--------
|
|
89
|
+
.. jupyter-execute::
|
|
90
|
+
:linenos:
|
|
91
|
+
:emphasize-lines: 9
|
|
92
|
+
|
|
93
|
+
import numpy as np
|
|
94
|
+
from lets_plot import *
|
|
95
|
+
LetsPlot.setup_html()
|
|
96
|
+
n = 30
|
|
97
|
+
np.random.seed(42)
|
|
98
|
+
x = np.random.uniform(-1, 1, size=n)
|
|
99
|
+
y = 25 * x ** 2 + np.random.normal(size=n)
|
|
100
|
+
ggplot({'x': x, 'y': y}, aes(x='x', y='y')) + \\
|
|
101
|
+
geom_point() + coord_fixed(ratio=.2, ylim=(7, 20))
|
|
102
|
+
|
|
103
|
+
"""
|
|
104
|
+
|
|
105
|
+
return _coord('fixed', ratio=ratio, xlim=xlim, ylim=ylim, flip=flip)
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
def coord_map(xlim=None, ylim=None, flip=False):
|
|
109
|
+
"""
|
|
110
|
+
Project a portion of the earth, which is approximately spherical,
|
|
111
|
+
onto a flat 2D plane.
|
|
112
|
+
Map projections generally do not preserve straight lines, so this requires considerable computation.
|
|
113
|
+
|
|
114
|
+
Parameters
|
|
115
|
+
----------
|
|
116
|
+
xlim : list
|
|
117
|
+
Limits (2 elements) for the x axis.
|
|
118
|
+
1st element defines lower limit, 2nd element defines upper limit.
|
|
119
|
+
None means no lower / upper bound - depending on the index in list.
|
|
120
|
+
ylim : list
|
|
121
|
+
Limits (2 elements) for the y axis.
|
|
122
|
+
1st element defines lower limit, 2nd element defines upper limit.
|
|
123
|
+
None means no lower / upper bound - depending on the index in list.
|
|
124
|
+
flip : bool
|
|
125
|
+
Flip the coordinate system axis so that horizontal axis becomes vertical and vice versa.
|
|
126
|
+
|
|
127
|
+
Returns
|
|
128
|
+
-------
|
|
129
|
+
``FeatureSpec``
|
|
130
|
+
Coordinate system specification.
|
|
131
|
+
|
|
132
|
+
Examples
|
|
133
|
+
--------
|
|
134
|
+
.. jupyter-execute::
|
|
135
|
+
:linenos:
|
|
136
|
+
:emphasize-lines: 6
|
|
137
|
+
|
|
138
|
+
from lets_plot import *
|
|
139
|
+
from lets_plot.geo_data import *
|
|
140
|
+
LetsPlot.setup_html()
|
|
141
|
+
us = geocode_states('US-48').get_boundaries(4)
|
|
142
|
+
ggplot() + geom_map(map=us, fill='gray', color='white') + \\
|
|
143
|
+
coord_map(xlim=(-130, -100))
|
|
144
|
+
|
|
145
|
+
"""
|
|
146
|
+
|
|
147
|
+
return _coord('map', xlim=xlim, ylim=ylim, flip=flip)
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
def coord_flip(xlim=None, ylim=None):
|
|
151
|
+
"""
|
|
152
|
+
Flip axis of default coordinate system so that horizontal axis becomes vertical and vice versa.
|
|
153
|
+
|
|
154
|
+
Parameters
|
|
155
|
+
----------
|
|
156
|
+
xlim : list
|
|
157
|
+
Limits (2 elements) for the x axis.
|
|
158
|
+
1st element defines lower limit, 2nd element defines upper limit.
|
|
159
|
+
None means no lower / upper bound - depending on the index in list.
|
|
160
|
+
ylim : list
|
|
161
|
+
Limits (2 elements) for the y axis.
|
|
162
|
+
1st element defines lower limit, 2nd element defines upper limit.
|
|
163
|
+
None means no lower / upper bound - depending on the index in list.
|
|
164
|
+
|
|
165
|
+
Returns
|
|
166
|
+
-------
|
|
167
|
+
``FeatureSpec``
|
|
168
|
+
Coordinate system specification.
|
|
169
|
+
|
|
170
|
+
Examples
|
|
171
|
+
--------
|
|
172
|
+
.. jupyter-execute::
|
|
173
|
+
:linenos:
|
|
174
|
+
:emphasize-lines: 12
|
|
175
|
+
|
|
176
|
+
import numpy as np
|
|
177
|
+
from lets_plot import *
|
|
178
|
+
LetsPlot.setup_html()
|
|
179
|
+
np.random.seed(42)
|
|
180
|
+
n = 10
|
|
181
|
+
x = np.arange(n)
|
|
182
|
+
y = 1 + np.random.randint(5, size=n)
|
|
183
|
+
ggplot() + \\
|
|
184
|
+
geom_bar(aes(x='x', y='y', fill='x'), data={'x': x, 'y': y}, \\
|
|
185
|
+
stat='identity', show_legend=False) + \\
|
|
186
|
+
scale_fill_discrete() + \\
|
|
187
|
+
coord_flip()
|
|
188
|
+
|
|
189
|
+
"""
|
|
190
|
+
|
|
191
|
+
return _coord('flip', xlim=xlim, ylim=ylim, flip=True)
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
def coord_polar(xlim=None, ylim=None, theta=None, start=None, direction=None, transform_bkgr=None):
|
|
195
|
+
"""
|
|
196
|
+
Polar coordinate system. It is used for pie charts and polar plots.
|
|
197
|
+
|
|
198
|
+
Parameters
|
|
199
|
+
----------
|
|
200
|
+
xlim : list
|
|
201
|
+
Limits (2 elements) for the x axis.
|
|
202
|
+
1st element defines lower limit, 2nd element defines upper limit.
|
|
203
|
+
None means no lower / upper bound - depending on the index in list.
|
|
204
|
+
ylim : list
|
|
205
|
+
Limits (2 elements) for the y axis.
|
|
206
|
+
1st element defines lower limit, 2nd element defines upper limit.
|
|
207
|
+
None means no lower / upper bound - depending on the index in list.
|
|
208
|
+
theta : {'x', 'y'}, default='x'
|
|
209
|
+
Aesthetic that is used to map angle.
|
|
210
|
+
start : float, default=0
|
|
211
|
+
Offset relative to the starting angle (which is 12 o'clock), in radians.
|
|
212
|
+
direction : {1, -1}, default=1
|
|
213
|
+
Specify angle direction, 1=clockwise, -1=counter-clockwise.
|
|
214
|
+
transform_bkgr : bool, default=True
|
|
215
|
+
If True, the background is transformed to a circle, rectangle otherwise.
|
|
216
|
+
|
|
217
|
+
Examples
|
|
218
|
+
--------
|
|
219
|
+
.. jupyter-execute::
|
|
220
|
+
:linenos:
|
|
221
|
+
:emphasize-lines: 13
|
|
222
|
+
|
|
223
|
+
import numpy as np
|
|
224
|
+
from lets_plot import *
|
|
225
|
+
LetsPlot.setup_html()
|
|
226
|
+
np.random.seed(42)
|
|
227
|
+
n = 20
|
|
228
|
+
data = {
|
|
229
|
+
'v': 1 + np.random.randint(5, size=n)
|
|
230
|
+
}
|
|
231
|
+
ggplot(data) + \\
|
|
232
|
+
geom_bar(aes(fill=as_discrete('v')), size=0, show_legend=False) + \\
|
|
233
|
+
scale_x_continuous(expand=[0, 0]) + \\
|
|
234
|
+
scale_y_continuous(expand=[0, 0]) + \\
|
|
235
|
+
coord_polar(theta='y')
|
|
236
|
+
|
|
237
|
+
"""
|
|
238
|
+
return _coord('polar', xlim=xlim, ylim=ylim, theta=theta, start=start, direction=direction, transform_bkgr=transform_bkgr)
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
def _coord(name, **other):
|
|
242
|
+
return FeatureSpec('coord', name=name, **other)
|