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.
Files changed (97) hide show
  1. lets_plot/__init__.py +382 -0
  2. lets_plot/_global_settings.py +192 -0
  3. lets_plot/_kbridge.py +197 -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 +106 -0
  8. lets_plot/bistro/corr.py +448 -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 +332 -0
  14. lets_plot/export/__init__.py +6 -0
  15. lets_plot/export/ggsave_.py +172 -0
  16. lets_plot/frontend_context/__init__.py +8 -0
  17. lets_plot/frontend_context/_configuration.py +140 -0
  18. lets_plot/frontend_context/_dynamic_configure_html.py +115 -0
  19. lets_plot/frontend_context/_frontend_ctx.py +16 -0
  20. lets_plot/frontend_context/_html_contexts.py +223 -0
  21. lets_plot/frontend_context/_intellij_python_json_ctx.py +38 -0
  22. lets_plot/frontend_context/_isolated_webview_panel_ctx.py +81 -0
  23. lets_plot/frontend_context/_json_contexts.py +39 -0
  24. lets_plot/frontend_context/_jupyter_notebook_ctx.py +82 -0
  25. lets_plot/frontend_context/_mime_types.py +7 -0
  26. lets_plot/frontend_context/_static_html_page_ctx.py +76 -0
  27. lets_plot/frontend_context/_static_svg_ctx.py +26 -0
  28. lets_plot/frontend_context/_webbr_html_page_ctx.py +29 -0
  29. lets_plot/frontend_context/sandbox.py +5 -0
  30. lets_plot/geo_data/__init__.py +19 -0
  31. lets_plot/geo_data/core.py +335 -0
  32. lets_plot/geo_data/geocoder.py +988 -0
  33. lets_plot/geo_data/geocodes.py +512 -0
  34. lets_plot/geo_data/gis/__init__.py +0 -0
  35. lets_plot/geo_data/gis/fluent_dict.py +201 -0
  36. lets_plot/geo_data/gis/geocoding_service.py +42 -0
  37. lets_plot/geo_data/gis/geometry.py +91 -0
  38. lets_plot/geo_data/gis/json_request.py +232 -0
  39. lets_plot/geo_data/gis/json_response.py +308 -0
  40. lets_plot/geo_data/gis/request.py +492 -0
  41. lets_plot/geo_data/gis/response.py +247 -0
  42. lets_plot/geo_data/livemap_helper.py +65 -0
  43. lets_plot/geo_data/to_geo_data_frame.py +141 -0
  44. lets_plot/geo_data/type_assertion.py +34 -0
  45. lets_plot/geo_data_internals/__init__.py +4 -0
  46. lets_plot/geo_data_internals/constants.py +13 -0
  47. lets_plot/geo_data_internals/utils.py +33 -0
  48. lets_plot/mapping.py +115 -0
  49. lets_plot/package_data/lets-plot.min.js +3 -0
  50. lets_plot/plot/__init__.py +64 -0
  51. lets_plot/plot/_global_theme.py +14 -0
  52. lets_plot/plot/annotation.py +290 -0
  53. lets_plot/plot/coord.py +242 -0
  54. lets_plot/plot/core.py +1071 -0
  55. lets_plot/plot/expand_limits_.py +78 -0
  56. lets_plot/plot/facet.py +210 -0
  57. lets_plot/plot/font_features.py +71 -0
  58. lets_plot/plot/geom.py +9146 -0
  59. lets_plot/plot/geom_extras.py +53 -0
  60. lets_plot/plot/geom_function_.py +219 -0
  61. lets_plot/plot/geom_imshow_.py +393 -0
  62. lets_plot/plot/geom_livemap_.py +343 -0
  63. lets_plot/plot/ggbunch_.py +96 -0
  64. lets_plot/plot/gggrid_.py +139 -0
  65. lets_plot/plot/ggtb_.py +81 -0
  66. lets_plot/plot/guide.py +231 -0
  67. lets_plot/plot/label.py +187 -0
  68. lets_plot/plot/marginal_layer.py +181 -0
  69. lets_plot/plot/plot.py +245 -0
  70. lets_plot/plot/pos.py +344 -0
  71. lets_plot/plot/sampling.py +338 -0
  72. lets_plot/plot/sandbox_.py +26 -0
  73. lets_plot/plot/scale.py +3580 -0
  74. lets_plot/plot/scale_colormap_mpl.py +300 -0
  75. lets_plot/plot/scale_convenience.py +155 -0
  76. lets_plot/plot/scale_identity_.py +653 -0
  77. lets_plot/plot/scale_position.py +1342 -0
  78. lets_plot/plot/series_meta.py +209 -0
  79. lets_plot/plot/stat.py +585 -0
  80. lets_plot/plot/subplots.py +331 -0
  81. lets_plot/plot/subplots_util.py +24 -0
  82. lets_plot/plot/theme_.py +790 -0
  83. lets_plot/plot/theme_set.py +418 -0
  84. lets_plot/plot/tooltip.py +486 -0
  85. lets_plot/plot/util.py +267 -0
  86. lets_plot/settings_utils.py +244 -0
  87. lets_plot/tilesets.py +429 -0
  88. lets_plot-4.8.1rc1.dist-info/METADATA +221 -0
  89. lets_plot-4.8.1rc1.dist-info/RECORD +97 -0
  90. lets_plot-4.8.1rc1.dist-info/WHEEL +6 -0
  91. lets_plot-4.8.1rc1.dist-info/licenses/LICENSE +21 -0
  92. lets_plot-4.8.1rc1.dist-info/licenses/licenses/LICENSE.FreeType +166 -0
  93. lets_plot-4.8.1rc1.dist-info/licenses/licenses/LICENSE.ImageMagick +106 -0
  94. lets_plot-4.8.1rc1.dist-info/licenses/licenses/LICENSE.expat +21 -0
  95. lets_plot-4.8.1rc1.dist-info/licenses/licenses/LICENSE.fontconfig +200 -0
  96. lets_plot-4.8.1rc1.dist-info/top_level.txt +2 -0
  97. lets_plot_kotlin_bridge.cpython-311-x86_64-linux-gnu.so +0 -0
@@ -0,0 +1,78 @@
1
+ # Copyright (c) 2024. 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 .core import aes
4
+ from .geom import geom_blank
5
+
6
+ __all__ = ['expand_limits']
7
+
8
+ def expand_limits(*, x=None, y=None, size=None, color=None, fill=None, alpha=None, shape=None):
9
+ """
10
+ Expand the plot limits to include additional data values.
11
+
12
+ This function extends the plot boundaries to encompass new data points,
13
+ whether a single value or multiple values are provided. It acts as a
14
+ thin wrapper around `geom_blank() <https://lets-plot.org/python/pages/api/lets_plot.geom_blank.html>`__.
15
+
16
+ Parameters
17
+ ----------
18
+ x, y, size, color, fill, alpha, shape : Any, list, tuple or range
19
+ List of name-value pairs specifying the value (or values) that should be included in each scale.
20
+ These parameters extend the corresponding plot dimensions or aesthetic scales.
21
+
22
+ Returns
23
+ -------
24
+ FeatureSpec
25
+ A result of the `geom_blank() <https://lets-plot.org/python/pages/api/lets_plot.geom_blank.html>`__ call.
26
+
27
+ Examples
28
+ --------
29
+ .. jupyter-execute::
30
+ :linenos:
31
+ :emphasize-lines: 10
32
+
33
+ from lets_plot import *
34
+ LetsPlot.setup_html()
35
+ data = {
36
+ 'x': [-3, 0, 1],
37
+ 'y': [2, 3, -1],
38
+ }
39
+
40
+ # Include the value -10 along the x-axis
41
+ ggplot(data, aes('x', 'y')) + geom_point() + \\
42
+ expand_limits(x=-10)
43
+
44
+ |
45
+
46
+ .. jupyter-execute::
47
+ :linenos:
48
+ :emphasize-lines: 10
49
+
50
+ from lets_plot import *
51
+ LetsPlot.setup_html()
52
+ data = {
53
+ 'x': [-3, 0, 1],
54
+ 'y': [2, 3, -1],
55
+ }
56
+
57
+ # Expand Limits Along the y-axis
58
+ ggplot(data, aes('x', 'y')) + geom_point() + \\
59
+ expand_limits(y=range(-10, 10))
60
+
61
+ """
62
+ params = locals()
63
+
64
+ def standardize(value):
65
+ if isinstance(value, (list, tuple, range)):
66
+ return list(value)
67
+ else:
68
+ return [value]
69
+
70
+ standardized = {k: standardize(v) for k, v in params.items()}
71
+
72
+ # Drop all undefined but keep x and y even if undefined.
73
+ cleaned = {k: v for k, v in standardized.items() if k in ['x', 'y'] or not all(e is None for e in v)}
74
+
75
+ max_length = max(len(v) for v in cleaned.values())
76
+ data = {k: v + [None] * (max_length - len(v)) for k, v in cleaned.items()}
77
+
78
+ return geom_blank(mapping=aes(**data))
@@ -0,0 +1,210 @@
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
+ # Facets display subsets of the dataset in different panels.
8
+
9
+
10
+ __all__ = ['facet_grid', 'facet_wrap']
11
+
12
+
13
+ def facet_grid(x=None, y=None, *, scales=None, x_order=1, y_order=1,
14
+ x_format=None, y_format=None,
15
+ x_labwidth=None, y_labwidth=None):
16
+ """
17
+ Split data by one or two faceting variables.
18
+ For each data subset creates a plot panel and lays out panels as grid.
19
+ The grid columns are defined by X faceting variable and rows are defined by Y faceting variable.
20
+
21
+ Parameters
22
+ ----------
23
+ x : str
24
+ Variable name which defines columns of the facet grid.
25
+ y : str
26
+ Variable name which defines rows of the facet grid.
27
+ scales : str
28
+ Specify whether scales are shared across all facets.
29
+ 'fixed' - shared (the default), 'free' - vary across both rows and columns,
30
+ 'free_x' or 'free_y' - vary across rows or columns respectively.
31
+ x_order : int, default=1
32
+ Specify ordering direction of columns. 1 - ascending, -1 - descending, 0 - no ordering.
33
+ y_order : int, default=1
34
+ Specify ordering direction of rows. 1 - ascending, -1 - descending, 0 - no ordering.
35
+ x_format : str
36
+ Specify the format pattern for displaying faceting values in columns.
37
+ y_format : str
38
+ Specify the format pattern for displaying faceting values in rows.
39
+ x_labwidth : int, default=None
40
+ The maximum label length (in characters) before a line breaking is applied.
41
+ If the original facet label already contains ``\\n`` as a text separator, it splits at those points first,
42
+ then wraps each part according to ``x_labwidth``.
43
+ y_labwidth : int, default=None
44
+ The maximum label length (in characters) before a line breaking is applied.
45
+ If the original facet label already contains ``\\n`` as a text separator, it splits at those points first,
46
+ then wraps each part according to ``y_labwidth``.
47
+
48
+ Returns
49
+ -------
50
+ ``FeatureSpec``
51
+ Facet grid specification.
52
+
53
+ Notes
54
+ -----
55
+ Format pattern in the ``x_format`` / ``y_format`` parameters can be
56
+ just a number format (like 'd') or a string template where number format
57
+ is surrounded by curly braces: "{d} cylinders".
58
+
59
+ For example:
60
+
61
+ - '.2f' -> '12.45',
62
+ - 'Score: {.2f}' -> 'Score: 12.45',
63
+ - 'Score: {}' -> 'Score: 12.454789'.
64
+
65
+ For more info see `Formatting <https://lets-plot.org/python/pages/formats.html>`__.
66
+
67
+ Examples
68
+ --------
69
+ .. jupyter-execute::
70
+ :linenos:
71
+ :emphasize-lines: 9
72
+
73
+ import numpy as np
74
+ from lets_plot import *
75
+ LetsPlot.setup_html()
76
+ n = 100
77
+ np.random.seed(42)
78
+ x = np.random.normal(size=n)
79
+ group = np.random.choice(['a', 'b'], size=n)
80
+ ggplot({'x': x, 'group': group}, aes(x='x')) + \\
81
+ geom_histogram() + facet_grid(x='group')
82
+
83
+ |
84
+
85
+ .. jupyter-execute::
86
+ :linenos:
87
+ :emphasize-lines: 11
88
+
89
+ import numpy as np
90
+ from lets_plot import *
91
+ LetsPlot.setup_html()
92
+ n = 1000
93
+ np.random.seed(42)
94
+ x = np.random.normal(size=n)
95
+ p = [1/6, 1/3, 1/2]
96
+ y = np.random.choice(p, size=n, p=p)
97
+ ggplot({'x': x, 'y': y}, aes(x='x')) + \\
98
+ geom_histogram() + \\
99
+ facet_grid(y='y', y_order=-1, y_format='.2f')
100
+
101
+ """
102
+ return _facet('grid',
103
+ x=x, y=y,
104
+ scales=scales,
105
+ x_order=x_order, y_order=y_order,
106
+ x_format=x_format, y_format=y_format,
107
+ x_labwidth=x_labwidth, y_labwidth=y_labwidth)
108
+
109
+
110
+ def facet_wrap(facets, ncol=None, nrow=None, *, scales=None, order=1, format=None, drop=None, dir="h", labwidth=None):
111
+ """
112
+ Split data by one or more faceting variables.
113
+ For each data subset creates a plot panel and lays out panels
114
+ according to the ``ncol``, ``nrow`` and ``dir`` settings.
115
+
116
+ Parameters
117
+ ----------
118
+ facets : str or list
119
+ One or more faceting variable names.
120
+ ncol : int
121
+ Number of columns.
122
+ nrow : int
123
+ Number of rows.
124
+ scales : str
125
+ Specifies whether scales are shared across all facets.
126
+ 'fixed' - shared (the default), 'free' - vary across both rows and columns,
127
+ 'free_x' or 'free_y' - vary across rows or columns respectively.
128
+ order : int or list, default=1
129
+ Specify the ordering direction of panels. 1 - ascending, -1 - descending, 0 - no ordering.
130
+ When a list is given, then values in the list are positionally matched to variables in ``facets``.
131
+ format : str or list
132
+ Specify the format pattern for displaying faceting values.
133
+ The ``format`` values are positionally matched to variables in ``facets``.
134
+ drop : bool, default=True
135
+ Specifies whether to drop unused factor levels (the default behavior)
136
+ or to show all factor levels regardless of whether they occur in the data.
137
+ dir : {'h', 'v'}, default='h'
138
+ Direction: either 'h' for horizontal or 'v' for vertical.
139
+ labwidth : int or list
140
+ The maximum label length (in characters) before a line breaking is applied.
141
+ If the original facet label already contains ``\\n`` as a text separator, it splits at those points first,
142
+ then wraps each part according to ``labwidth``.
143
+
144
+
145
+ Returns
146
+ -------
147
+ ``FeatureSpec``
148
+ Facet wrap specification.
149
+
150
+ Notes
151
+ -----
152
+ Format patterns in the ``format`` parameter can be just a number format (like 'd') or
153
+ a string template where number format is surrounded by curly braces: "{d} cylinders".
154
+
155
+ For example:
156
+
157
+ - '.2f' -> '12.45',
158
+ - 'Score: {.2f}' -> 'Score: 12.45',
159
+ - 'Score: {}' -> 'Score: 12.454789'.
160
+
161
+ For more info see `Formatting <https://lets-plot.org/python/pages/formats.html>`__.
162
+
163
+ Examples
164
+ --------
165
+ .. jupyter-execute::
166
+ :linenos:
167
+ :emphasize-lines: 9
168
+
169
+ import numpy as np
170
+ from lets_plot import *
171
+ LetsPlot.setup_html()
172
+ n = 100
173
+ np.random.seed(42)
174
+ x = np.random.normal(size=n)
175
+ group = np.random.choice(['a', 'b'], size=n)
176
+ ggplot({'x': x, 'group': group}, aes(x='x')) + \\
177
+ geom_histogram() + facet_wrap(facets='group')
178
+
179
+ |
180
+
181
+ .. jupyter-execute::
182
+ :linenos:
183
+ :emphasize-lines: 11
184
+
185
+ import numpy as np
186
+ from lets_plot import *
187
+ LetsPlot.setup_html()
188
+ n = 1000
189
+ np.random.seed(42)
190
+ x = np.random.normal(size=n)
191
+ p = [1/6, 1/3, 1/2]
192
+ y = np.random.choice(p, size=n, p=p)
193
+ ggplot({'x': x, 'y': y}, aes(x='x')) + \\
194
+ geom_histogram() + \\
195
+ facet_wrap(facets='y', order=-1, ncol=2, dir='v', format='.2f')
196
+
197
+ """
198
+ return _facet('wrap',
199
+ facets=facets,
200
+ ncol=ncol, nrow=nrow,
201
+ scales=scales,
202
+ order=order,
203
+ format=format,
204
+ drop=drop,
205
+ dir=dir,
206
+ labwidth=labwidth)
207
+
208
+
209
+ def _facet(name, **kwargs):
210
+ return FeatureSpec('facet', name=name, **kwargs)
@@ -0,0 +1,71 @@
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
+ import numbers
4
+
5
+ from lets_plot.plot.core import FeatureSpec
6
+
7
+ __all__ = ['font_metrics_adjustment', 'font_family_info']
8
+
9
+
10
+ def font_metrics_adjustment(width_correction: numbers.Real) -> FeatureSpec:
11
+ """
12
+ Adjust estimated width of text labels on plot.
13
+
14
+ Allow for manual correction in a rare cases when plot layout looks broken
15
+ due to either overestimation or underestimation of size of text labels on plot.
16
+
17
+ Parameters
18
+ ----------
19
+ width_correction : number
20
+ Correcting coefficient applied to default width estimate of a text label.
21
+
22
+ Returns
23
+ -------
24
+ ``FeatureSpec``
25
+ Metainfo specification.
26
+
27
+ Notes
28
+ -----
29
+ Can be mixed with other plot features in a plot-expression:
30
+
31
+ p + ggsize(300, 500) + font_metrics_adjustment(1.3)
32
+
33
+ """
34
+ return FeatureSpec('metainfo', name='font_metrics_adjustment',
35
+ width_correction=width_correction)
36
+
37
+
38
+ def font_family_info(family: str, width_correction: numbers.Real = None, mono: bool = None) -> FeatureSpec:
39
+ """
40
+ Specify properties of a particular font-family to adjust estimated width of text labels on plot.
41
+
42
+ Might be useful when some exotic font-family is used that causes issues with the plot layout.
43
+
44
+ Allow for manual correction in a rare cases when plot layout looks broken
45
+ due to either overestimation or underestimation of size of text labels on plot.
46
+
47
+ Parameters
48
+ ----------
49
+ family : str
50
+ Font family.
51
+ width_correction : number, optional
52
+ Correcting coefficient applied to default width estimate of a text label.
53
+ mono : bool, optional
54
+ When True - the font is marked as 'monospaced'.
55
+
56
+ Returns
57
+ -------
58
+ ``FeatureSpec``
59
+ Metainfo specification.
60
+
61
+ Notes
62
+ -----
63
+ Can be mixed with other plot features in a plot-expression:
64
+
65
+ p + ggsize(300, 500) + font_family_info("HyperFont", mono=True)
66
+
67
+ """
68
+ return FeatureSpec('metainfo', name='font_family_info',
69
+ family=family,
70
+ width_correction=width_correction,
71
+ monospaced=mono)