From 245ae4c3a39eb19cb878e5fae9b8cd77f4e4b301 Mon Sep 17 00:00:00 2001 From: Artem Smirnov Date: Tue, 7 May 2024 14:42:01 +0200 Subject: [PATCH 1/8] Fix #1093. --- future_changes.md | 1 + .../lets_plot/plot/geom_livemap_.py | 19 ++++++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/future_changes.md b/future_changes.md index cb6c690e030..f0f62dc710c 100644 --- a/future_changes.md +++ b/future_changes.md @@ -6,4 +6,5 @@ ### Fixed +- Livemap: improve "tiles" documentation [[#1093](https://github.com/JetBrains/lets-plot/issues/1093)]. - Undesired vertical scroller when displaying `gggrid` in Jupyter notebook. diff --git a/python-package/lets_plot/plot/geom_livemap_.py b/python-package/lets_plot/plot/geom_livemap_.py index b19d0b2fd78..88cd0cc4006 100644 --- a/python-package/lets_plot/plot/geom_livemap_.py +++ b/python-package/lets_plot/plot/geom_livemap_.py @@ -50,9 +50,22 @@ def geom_livemap(*, 'epsg4326' for Equirectangular projection. `projection` only works with vector map tiles (i.e. Lets-Plot map tiles). tiles : str - Tiles provider, either as a string - URL for a standard raster ZXY tile provider - with {z}, {x} and {y} wildcards (e.g. 'http://my.tile.com/{z}/{x}/{y}.png') - or the result of a call to a `maptiles_xxx()` functions. + Tile provider. + + To use vector tiles, pass the result of the `maptiles_lets_plot()` function. + + To use a solid color as tiles, pass the result of the `maptiles_solid()` function. + + To use raster tiles, pass the result of the `maptiles_zxy()` function. + As an alternative to this function, you can explicitly pass a string - + URL to a standard raster ZXY tile provider with {z}, {x} and {y} wildcards + (e.g. 'http://my.tile.com/{z}/{x}/{y}.png'). + + The easiest way is to select tiles from a predefined list of constants + provided by the `tilesets` module. + + More information about tiles can be found here: + https://lets-plot.org/python/pages/basemap_tiles.html show_coord_pick_tools : bool, default=False Show buttons "copy location" and "draw geometry". data_size_zoomin : int, default=0 From 99c360b140295e2f1af4b48ff81b193cf3c8328a Mon Sep 17 00:00:00 2001 From: Artem Smirnov Date: Tue, 7 May 2024 14:45:08 +0200 Subject: [PATCH 2/8] Tiny fix in docstrings (in style) of the setup_show_ext() method. --- python-package/lets_plot/__init__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/python-package/lets_plot/__init__.py b/python-package/lets_plot/__init__.py index 8abb5f70258..741a3a8b772 100644 --- a/python-package/lets_plot/__init__.py +++ b/python-package/lets_plot/__init__.py @@ -236,7 +236,7 @@ def setup_show_ext(cls, *, # Show the plot in the Chrome web browser for Windows. # This is the default setup path. Replace the file path with your own if it differs. from lets_plot import * - LetsPlot.setup_show_ext(exec = 'C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe --app=%s') + LetsPlot.setup_show_ext(exec='C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe --app=%s') p = ggplot() + geom_point(x=0, y=0) p.show() @@ -248,7 +248,7 @@ def setup_show_ext(cls, *, # Show the plot in the Safari web browser for macOS. from lets_plot import * - LetsPlot.setup_show_ext(exec = 'open -a safari %s') + LetsPlot.setup_show_ext(exec='open -a safari %s') p = ggplot() + geom_point(x=0, y=0) p.show() @@ -261,7 +261,7 @@ def setup_show_ext(cls, *, # Show the plot in the Chrome web browser for macOS in the application mode. # This is the default setup path. Replace the path with your own if it differs. from lets_plot import * - LetsPlot.setup_show_ext(exec = '/Applications/Google\\ Chrome.app/Contents/MacOS/Google\\ Chrome --app=%s') + LetsPlot.setup_show_ext(exec='/Applications/Google\\ Chrome.app/Contents/MacOS/Google\\ Chrome --app=%s') p = ggplot() + geom_point(x=0, y=0) p.show() @@ -273,7 +273,7 @@ def setup_show_ext(cls, *, # Show the plot in the Chrome web browser for Linux. from lets_plot import * - LetsPlot.setup_show_ext(exec = 'google-chrome --app=%s') + LetsPlot.setup_show_ext(exec='google-chrome --app=%s') p = ggplot() + geom_point(x=0, y=0) p.show() From 3f6de60f36e277b0a47a0712630848b1ebc951b9 Mon Sep 17 00:00:00 2001 From: Artem Smirnov Date: Tue, 7 May 2024 14:53:09 +0200 Subject: [PATCH 3/8] Update in docstrings for the explode aesthetic of the geom_pie(). --- python-package/lets_plot/plot/geom.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python-package/lets_plot/plot/geom.py b/python-package/lets_plot/plot/geom.py index 855cb566e69..a335ba9706f 100644 --- a/python-package/lets_plot/plot/geom.py +++ b/python-package/lets_plot/plot/geom.py @@ -6597,7 +6597,7 @@ def geom_pie(mapping=None, *, data=None, stat=None, position=None, show_legend=N - x : x-axis value. - y : y-axis value. - slice : values associated to pie sectors. - - explode : values to explode slices away from their center point, detaching it from the main pie. + - explode : values to explode slices away from their center point, detaching it from the main pie. The optimal range for the values is between 0 and 1-`hole`. - size : pie diameter. - fill : fill color. String in the following formats: RGB/RGBA (e.g. "rgb(0, 0, 255)"); HEX (e.g. "#0000FF"); color name (e.g. "red"); role name ("pen", "paper" or "brush"). - alpha : transparency level of the pie. Accept values between 0 and 1. From 518c7ba8ee66e9047eb4d9621260b6d17bd7e80b Mon Sep 17 00:00:00 2001 From: Artem Smirnov Date: Tue, 7 May 2024 17:51:02 +0200 Subject: [PATCH 4/8] Small fix in docstrings for the geom_livemap() function. --- python-package/lets_plot/plot/geom_livemap_.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/python-package/lets_plot/plot/geom_livemap_.py b/python-package/lets_plot/plot/geom_livemap_.py index 88cd0cc4006..58fdfcfbfa6 100644 --- a/python-package/lets_plot/plot/geom_livemap_.py +++ b/python-package/lets_plot/plot/geom_livemap_.py @@ -54,8 +54,6 @@ def geom_livemap(*, To use vector tiles, pass the result of the `maptiles_lets_plot()` function. - To use a solid color as tiles, pass the result of the `maptiles_solid()` function. - To use raster tiles, pass the result of the `maptiles_zxy()` function. As an alternative to this function, you can explicitly pass a string - URL to a standard raster ZXY tile provider with {z}, {x} and {y} wildcards From 8aca1a4e712d03e0e4fbd65215d4af1e0c2354d0 Mon Sep 17 00:00:00 2001 From: Artem Smirnov Date: Tue, 7 May 2024 18:12:24 +0200 Subject: [PATCH 5/8] Small fix in docstrings for the explode parameter of the geom_pie() function. --- python-package/lets_plot/plot/geom.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python-package/lets_plot/plot/geom.py b/python-package/lets_plot/plot/geom.py index a335ba9706f..43f7bee29e0 100644 --- a/python-package/lets_plot/plot/geom.py +++ b/python-package/lets_plot/plot/geom.py @@ -6597,7 +6597,7 @@ def geom_pie(mapping=None, *, data=None, stat=None, position=None, show_legend=N - x : x-axis value. - y : y-axis value. - slice : values associated to pie sectors. - - explode : values to explode slices away from their center point, detaching it from the main pie. The optimal range for the values is between 0 and 1-`hole`. + - explode : values to explode slices away from their center point, detaching it from the main pie. Accept values between 0 and 1. - size : pie diameter. - fill : fill color. String in the following formats: RGB/RGBA (e.g. "rgb(0, 0, 255)"); HEX (e.g. "#0000FF"); color name (e.g. "red"); role name ("pen", "paper" or "brush"). - alpha : transparency level of the pie. Accept values between 0 and 1. From 81ef4b17100440089abbcde8f53809cbce5f0b3a Mon Sep 17 00:00:00 2001 From: Artem Smirnov Date: Tue, 7 May 2024 19:19:05 +0200 Subject: [PATCH 6/8] Fix in docstrings for the geom_livemap() function. --- .../lets_plot/plot/geom_livemap_.py | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/python-package/lets_plot/plot/geom_livemap_.py b/python-package/lets_plot/plot/geom_livemap_.py index 58fdfcfbfa6..e1a1f01f1cf 100644 --- a/python-package/lets_plot/plot/geom_livemap_.py +++ b/python-package/lets_plot/plot/geom_livemap_.py @@ -50,17 +50,11 @@ def geom_livemap(*, 'epsg4326' for Equirectangular projection. `projection` only works with vector map tiles (i.e. Lets-Plot map tiles). tiles : str - Tile provider. + Tile provider: - To use vector tiles, pass the result of the `maptiles_lets_plot()` function. - - To use raster tiles, pass the result of the `maptiles_zxy()` function. - As an alternative to this function, you can explicitly pass a string - - URL to a standard raster ZXY tile provider with {z}, {x} and {y} wildcards - (e.g. 'http://my.tile.com/{z}/{x}/{y}.png'). - - The easiest way is to select tiles from a predefined list of constants - provided by the `tilesets` module. + - pass a predefined constant from the `tilesets` module (Lets-Plot's vector tiles, e.g. LETS_PLOT_COLOR, or outer raster tiles, e.g. OPEN_TOPO_MAP); + - pass a URL for a standard raster ZXY tile provider with {z}, {x} and {y} wildcards (e.g. 'http://my.tile.com/{z}/{x}/{y}.png') if the required tileset isn't in the module; + - pass the result of a call to a `maptiles_zxy()` function if further customisation is required (e.g. attribution or zoom). More information about tiles can be found here: https://lets-plot.org/python/pages/basemap_tiles.html @@ -106,9 +100,10 @@ def geom_livemap(*, .. jupyter-execute:: :linenos: - :emphasize-lines: 9 + :emphasize-lines: 10 from lets_plot import * + from lets_plot import tilesets LetsPlot.setup_html() data = { 'city': ['New York City', 'Prague'], @@ -116,7 +111,7 @@ def geom_livemap(*, 'lat': [40.6408, 50.073658], } ggplot(data, aes(x='lon', y='lat')) + \\ - geom_livemap(projection='epsg4326', tiles=maptiles_lets_plot(theme='dark')) + \\ + geom_livemap(projection='epsg4326', tiles=tilesets.LETS_PLOT_DARK) + \\ geom_path(color='white', geodesic=True) + \\ geom_point(color='white', tooltips=layer_tooltips().line('@city')) + \\ ggtitle("The shortest path between New York and Prague") From 0e52afed9e57480784c27963550406e0edb6eae7 Mon Sep 17 00:00:00 2001 From: Artem Smirnov Date: Wed, 8 May 2024 11:32:56 +0200 Subject: [PATCH 7/8] Another tiny fix in docstrings for the geom_livemap() function. --- python-package/lets_plot/plot/geom_livemap_.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python-package/lets_plot/plot/geom_livemap_.py b/python-package/lets_plot/plot/geom_livemap_.py index e1a1f01f1cf..8dc4ac12df2 100644 --- a/python-package/lets_plot/plot/geom_livemap_.py +++ b/python-package/lets_plot/plot/geom_livemap_.py @@ -52,8 +52,8 @@ def geom_livemap(*, tiles : str Tile provider: - - pass a predefined constant from the `tilesets` module (Lets-Plot's vector tiles, e.g. LETS_PLOT_COLOR, or outer raster tiles, e.g. OPEN_TOPO_MAP); - - pass a URL for a standard raster ZXY tile provider with {z}, {x} and {y} wildcards (e.g. 'http://my.tile.com/{z}/{x}/{y}.png') if the required tileset isn't in the module; + - pass a predefined constant from the `tilesets` module (Lets-Plot's vector tiles, e.g. LETS_PLOT_COLOR, or external raster tiles, e.g. OPEN_TOPO_MAP); + - pass a URL for a standard raster ZXY tile provider with {z}, {x} and {y} wildcards (e.g. 'http://my.tile.com/{z}/{x}/{y}.png') if the required tileset not present in the module; - pass the result of a call to a `maptiles_zxy()` function if further customisation is required (e.g. attribution or zoom). More information about tiles can be found here: From b6f43966fe45773b86e66c80bff07ec416d5035f Mon Sep 17 00:00:00 2001 From: Artem Smirnov Date: Wed, 8 May 2024 11:49:03 +0200 Subject: [PATCH 8/8] Add quotes to the docstrings for the geom_livemap() function. --- python-package/lets_plot/plot/geom_livemap_.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python-package/lets_plot/plot/geom_livemap_.py b/python-package/lets_plot/plot/geom_livemap_.py index 8dc4ac12df2..6e3e1912f1c 100644 --- a/python-package/lets_plot/plot/geom_livemap_.py +++ b/python-package/lets_plot/plot/geom_livemap_.py @@ -52,7 +52,7 @@ def geom_livemap(*, tiles : str Tile provider: - - pass a predefined constant from the `tilesets` module (Lets-Plot's vector tiles, e.g. LETS_PLOT_COLOR, or external raster tiles, e.g. OPEN_TOPO_MAP); + - pass a predefined constant from the `tilesets` module (Lets-Plot's vector tiles, e.g. `LETS_PLOT_COLOR`, or external raster tiles, e.g. `OPEN_TOPO_MAP`); - pass a URL for a standard raster ZXY tile provider with {z}, {x} and {y} wildcards (e.g. 'http://my.tile.com/{z}/{x}/{y}.png') if the required tileset not present in the module; - pass the result of a call to a `maptiles_zxy()` function if further customisation is required (e.g. attribution or zoom).