From 9c2efed51d388669423120dd251fd171eb192cd6 Mon Sep 17 00:00:00 2001 From: Florence Haudin Date: Mon, 8 Aug 2022 19:48:23 +0200 Subject: [PATCH 01/13] Adapt Heatmap layer for an easier use with a ColormapControl. --- ipyleaflet/leaflet.py | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/ipyleaflet/leaflet.py b/ipyleaflet/leaflet.py index fe6952b87..431061ffa 100644 --- a/ipyleaflet/leaflet.py +++ b/ipyleaflet/leaflet.py @@ -8,7 +8,7 @@ import xyzservices from datetime import date, timedelta from math import isnan -from branca.colormap import linear, ColorMap +from branca.colormap import linear, LinearColormap, ColorMap from IPython.display import display import warnings @@ -799,8 +799,16 @@ class Heatmap(RasterLayer): Radius of the data points. blur: float, default 15. Blurring intensity. - gradient: dict, default {0.4: 'blue', 0.6: 'cyan', 0.7: 'lime', 0.8: 'yellow', 1.0: 'red'} + values : list, default [0.4, 0.6, 0.7, 0.8, 1.0] + list of values to define the gradient + colors : list, default ['blue', 'cyan', 'lime', 'yellow', 'red'] + list of colors to define the gradient + dict: dict, default built from values (keys) and colors lists (values) + dictionnary mapping value to colors. + gradient : Dict, default built from dict Colors used for the color-mapping from low to high heatmap intensity. + colormap: branca.colormap.LinearColorMap instance + The colormap used for displaying the HeatMap data, defined with the same min and max values and colors than the gradient. """ _view_name = Unicode('LeafletHeatmapView').tag(sync=True) @@ -815,6 +823,15 @@ class Heatmap(RasterLayer): radius = Float(25.0).tag(sync=True, o=True) blur = Float(15.0).tag(sync=True, o=True) gradient = Dict({0.4: 'blue', 0.6: 'cyan', 0.7: 'lime', 0.8: 'yellow', 1.0: 'red'}).tag(sync=True, o=True) + colors = ['blue', 'cyan', 'lime', 'yellow', 'red'] + values = [0.4, 0.6, 0.7, 0.8, 1.0] + dict ={} + for i in range(len(values)): + dict[values[i]] = colors[i] + vmin = values[0] + vmax = values[len(values)-1] + gradient = Dict(dict).tag(sync=True, o=True) + colormap = LinearColormap(colors, vmin=vmin, vmax=vmax) class VectorTileLayer(Layer): From e8bbcc04926fc9cdb29de674d1c728aae2ab5248 Mon Sep 17 00:00:00 2001 From: Florence Haudin Date: Mon, 8 Aug 2022 19:56:52 +0200 Subject: [PATCH 02/13] Fix flake8 formatting issue. --- ipyleaflet/leaflet.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ipyleaflet/leaflet.py b/ipyleaflet/leaflet.py index 431061ffa..5afa38025 100644 --- a/ipyleaflet/leaflet.py +++ b/ipyleaflet/leaflet.py @@ -825,11 +825,11 @@ class Heatmap(RasterLayer): gradient = Dict({0.4: 'blue', 0.6: 'cyan', 0.7: 'lime', 0.8: 'yellow', 1.0: 'red'}).tag(sync=True, o=True) colors = ['blue', 'cyan', 'lime', 'yellow', 'red'] values = [0.4, 0.6, 0.7, 0.8, 1.0] - dict ={} + dict = {} for i in range(len(values)): dict[values[i]] = colors[i] vmin = values[0] - vmax = values[len(values)-1] + vmax = values[len(values) - 1] gradient = Dict(dict).tag(sync=True, o=True) colormap = LinearColormap(colors, vmin=vmin, vmax=vmax) From 93fa3c40e40500cb386fa9fd645d01f2415bd2b5 Mon Sep 17 00:00:00 2001 From: Florence Haudin Date: Tue, 9 Aug 2022 17:13:20 +0200 Subject: [PATCH 03/13] Simplify the logics of attributes of Heatmap class and compute vmin, vmax and colormap from gradient data (values and colors). --- examples/Heatmap_with_colormap.ipynb | 88 ++++++++++++++++++++++++++++ ipyleaflet/leaflet.py | 24 +++++--- 2 files changed, 103 insertions(+), 9 deletions(-) create mode 100644 examples/Heatmap_with_colormap.ipynb diff --git a/examples/Heatmap_with_colormap.ipynb b/examples/Heatmap_with_colormap.ipynb new file mode 100644 index 000000000..ddaf3966e --- /dev/null +++ b/examples/Heatmap_with_colormap.ipynb @@ -0,0 +1,88 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "id": "98958552-db61-4b15-9025-8483234118b3", + "metadata": {}, + "outputs": [], + "source": [ + "# Set up for JupyterLite\n", + "try:\n", + " import piplite\n", + " await piplite.install('ipyleaflet')\n", + "except ImportError:\n", + " pass" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "974bc9b2-4a25-455b-8c4d-ca565e21f146", + "metadata": {}, + "outputs": [], + "source": [ + "import ipyleaflet\n", + "from random import uniform\n", + "import time\n", + "from branca.colormap import linear, LinearColormap" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "fa27e0da-7047-4f06-93e8-3fb230e554d4", + "metadata": {}, + "outputs": [], + "source": [ + "def create_random_data(length):\n", + " \"Return a list of some random lat/lon/value triples.\"\n", + " return [\n", + " [uniform(-80, 80), uniform(-180, 180), uniform(0, 1000)] for i in range(length)\n", + " ]" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "cd1fc9dd-addf-4085-95ff-b8d4b983491f", + "metadata": {}, + "outputs": [], + "source": [ + "m = ipyleaflet.Map(center=[0, 0], zoom=2)\n", + "heat = ipyleaflet.Heatmap(locations=create_random_data(1000), radius=20, blur=10, gradient={0.25 : 'orange', 0.85 : 'red'})\n", + "colormap_control = ipyleaflet.ColormapControl(\n", + " caption='Intensity',\n", + " colormap=heat.colormap,\n", + " value_min=heat.vmin,\n", + " value_max=heat.vmax,\n", + " position='topright',\n", + " transparent_bg=True,\n", + " )\n", + "m.add(heat)\n", + "m.add(colormap_control)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.13" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/ipyleaflet/leaflet.py b/ipyleaflet/leaflet.py index 5afa38025..a11580931 100644 --- a/ipyleaflet/leaflet.py +++ b/ipyleaflet/leaflet.py @@ -823,15 +823,21 @@ class Heatmap(RasterLayer): radius = Float(25.0).tag(sync=True, o=True) blur = Float(15.0).tag(sync=True, o=True) gradient = Dict({0.4: 'blue', 0.6: 'cyan', 0.7: 'lime', 0.8: 'yellow', 1.0: 'red'}).tag(sync=True, o=True) - colors = ['blue', 'cyan', 'lime', 'yellow', 'red'] - values = [0.4, 0.6, 0.7, 0.8, 1.0] - dict = {} - for i in range(len(values)): - dict[values[i]] = colors[i] - vmin = values[0] - vmax = values[len(values) - 1] - gradient = Dict(dict).tag(sync=True, o=True) - colormap = LinearColormap(colors, vmin=vmin, vmax=vmax) + + def __init__(self, **kwargs): + super(Heatmap, self).__init__(**kwargs) + self.data = self._get_data() + + @observe('color_mapping') + def _updata_data(self, change): + self.data = self._get_data() + + def _get_data(self): + self.values = list(self.gradient.keys()) + self.colors = list(self.gradient.values()) + self.vmin = self.values[0] + self.vmax = self.values[len(self.values) - 1] + self.colormap = LinearColormap(self.colors, vmin=self.vmin, vmax=self.vmax) class VectorTileLayer(Layer): From 92ff4475b86019a52cd1eb0b7a59dab73a77152a Mon Sep 17 00:00:00 2001 From: Florence Haudin Date: Tue, 9 Aug 2022 17:39:38 +0200 Subject: [PATCH 04/13] Update docstrings and change self.values/self.colors into values/colors in _get_data. --- ipyleaflet/leaflet.py | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/ipyleaflet/leaflet.py b/ipyleaflet/leaflet.py index a11580931..9e7d6856f 100644 --- a/ipyleaflet/leaflet.py +++ b/ipyleaflet/leaflet.py @@ -799,14 +799,12 @@ class Heatmap(RasterLayer): Radius of the data points. blur: float, default 15. Blurring intensity. - values : list, default [0.4, 0.6, 0.7, 0.8, 1.0] - list of values to define the gradient - colors : list, default ['blue', 'cyan', 'lime', 'yellow', 'red'] - list of colors to define the gradient - dict: dict, default built from values (keys) and colors lists (values) - dictionnary mapping value to colors. - gradient : Dict, default built from dict + gradient : Dict, default {0.4: 'blue', 0.6: 'cyan', 0.7: 'lime', 0.8: 'yellow', 1.0: 'red'} Colors used for the color-mapping from low to high heatmap intensity. + vmin : float, default 0.4 + Minimum value of the color mapping + vmax : float, default 1.0 + Maximum value of the color mapping colormap: branca.colormap.LinearColorMap instance The colormap used for displaying the HeatMap data, defined with the same min and max values and colors than the gradient. """ @@ -833,11 +831,11 @@ def _updata_data(self, change): self.data = self._get_data() def _get_data(self): - self.values = list(self.gradient.keys()) - self.colors = list(self.gradient.values()) - self.vmin = self.values[0] - self.vmax = self.values[len(self.values) - 1] - self.colormap = LinearColormap(self.colors, vmin=self.vmin, vmax=self.vmax) + values = list(self.gradient.keys()) + colors = list(self.gradient.values()) + self.vmin = values[0] + self.vmax = values[len(values) - 1] + self.colormap = LinearColormap(colors, vmin=self.vmin, vmax=self.vmax) class VectorTileLayer(Layer): From 867553159c988f474b9c660cbf7e89dd76a1cb7b Mon Sep 17 00:00:00 2001 From: Florence Haudin Date: Tue, 9 Aug 2022 17:58:50 +0200 Subject: [PATCH 05/13] Update obsolete argument in @observe decorator. --- ipyleaflet/leaflet.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ipyleaflet/leaflet.py b/ipyleaflet/leaflet.py index 9e7d6856f..aedec5d15 100644 --- a/ipyleaflet/leaflet.py +++ b/ipyleaflet/leaflet.py @@ -826,7 +826,7 @@ def __init__(self, **kwargs): super(Heatmap, self).__init__(**kwargs) self.data = self._get_data() - @observe('color_mapping') + @observe('gradient') def _updata_data(self, change): self.data = self._get_data() From b3d0cd558ce9f11322c6da2f0e7ec7683fcee46e Mon Sep 17 00:00:00 2001 From: HaudinFlorence <99649086+HaudinFlorence@users.noreply.github.com> Date: Wed, 10 Aug 2022 11:42:38 +0200 Subject: [PATCH 06/13] Update ipyleaflet/leaflet.py Update docstrings Co-authored-by: David Brochart --- ipyleaflet/leaflet.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ipyleaflet/leaflet.py b/ipyleaflet/leaflet.py index aedec5d15..5511eb5a8 100644 --- a/ipyleaflet/leaflet.py +++ b/ipyleaflet/leaflet.py @@ -799,7 +799,7 @@ class Heatmap(RasterLayer): Radius of the data points. blur: float, default 15. Blurring intensity. - gradient : Dict, default {0.4: 'blue', 0.6: 'cyan', 0.7: 'lime', 0.8: 'yellow', 1.0: 'red'} + gradient : dict, default {0.4: 'blue', 0.6: 'cyan', 0.7: 'lime', 0.8: 'yellow', 1.0: 'red'} Colors used for the color-mapping from low to high heatmap intensity. vmin : float, default 0.4 Minimum value of the color mapping From 0e186d12cd7db5f394b9dbc85f1dfea5e888e5b8 Mon Sep 17 00:00:00 2001 From: HaudinFlorence <99649086+HaudinFlorence@users.noreply.github.com> Date: Wed, 10 Aug 2022 11:42:53 +0200 Subject: [PATCH 07/13] Update ipyleaflet/leaflet.py Co-authored-by: David Brochart --- ipyleaflet/leaflet.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ipyleaflet/leaflet.py b/ipyleaflet/leaflet.py index 5511eb5a8..9593d16b4 100644 --- a/ipyleaflet/leaflet.py +++ b/ipyleaflet/leaflet.py @@ -834,7 +834,7 @@ def _get_data(self): values = list(self.gradient.keys()) colors = list(self.gradient.values()) self.vmin = values[0] - self.vmax = values[len(values) - 1] + self.vmax = values[-1] self.colormap = LinearColormap(colors, vmin=self.vmin, vmax=self.vmax) From 6f8773e9970c9dd799dadd798aaaab3ef2bdc854 Mon Sep 17 00:00:00 2001 From: Florence Haudin Date: Tue, 9 Aug 2022 17:58:50 +0200 Subject: [PATCH 08/13] Update obsolete argument in @observe decorator. --- examples/Heatmap_with_colormap.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/Heatmap_with_colormap.ipynb b/examples/Heatmap_with_colormap.ipynb index ddaf3966e..4d29c73e9 100644 --- a/examples/Heatmap_with_colormap.ipynb +++ b/examples/Heatmap_with_colormap.ipynb @@ -50,7 +50,7 @@ "outputs": [], "source": [ "m = ipyleaflet.Map(center=[0, 0], zoom=2)\n", - "heat = ipyleaflet.Heatmap(locations=create_random_data(1000), radius=20, blur=10, gradient={0.25 : 'orange', 0.85 : 'red'})\n", + "heat = ipyleaflet.Heatmap(locations=create_random_data(1000), radius=20, blur=10, gradient={0.1 : 'orange', 0.2 : 'red', 1.0 :'black'})\n", "colormap_control = ipyleaflet.ColormapControl(\n", " caption='Intensity',\n", " colormap=heat.colormap,\n", From e1674ce93ef4a210f3f95e88bd81ac96dffc53a2 Mon Sep 17 00:00:00 2001 From: Florence Haudin Date: Wed, 10 Aug 2022 12:08:11 +0200 Subject: [PATCH 09/13] Add index argument in LinearColormap to properly set a piecewise linear colormap with custom boundary colors and values. --- ipyleaflet/leaflet.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ipyleaflet/leaflet.py b/ipyleaflet/leaflet.py index 9593d16b4..9a1209366 100644 --- a/ipyleaflet/leaflet.py +++ b/ipyleaflet/leaflet.py @@ -835,7 +835,7 @@ def _get_data(self): colors = list(self.gradient.values()) self.vmin = values[0] self.vmax = values[-1] - self.colormap = LinearColormap(colors, vmin=self.vmin, vmax=self.vmax) + self.colormap = LinearColormap(colors=colors, index=values, vmin=self.vmin, vmax=self.vmax) class VectorTileLayer(Layer): From 27acdace5166daa4e541b65fd23b55d83f7bae9e Mon Sep 17 00:00:00 2001 From: Florence Haudin Date: Wed, 10 Aug 2022 15:09:57 +0200 Subject: [PATCH 10/13] Change values to colormap_labels in _get_data method . --- ipyleaflet/leaflet.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ipyleaflet/leaflet.py b/ipyleaflet/leaflet.py index 9a1209366..f51b6496a 100644 --- a/ipyleaflet/leaflet.py +++ b/ipyleaflet/leaflet.py @@ -831,11 +831,11 @@ def _updata_data(self, change): self.data = self._get_data() def _get_data(self): - values = list(self.gradient.keys()) + colormap_labels = list(self.gradient.keys()) colors = list(self.gradient.values()) - self.vmin = values[0] - self.vmax = values[-1] - self.colormap = LinearColormap(colors=colors, index=values, vmin=self.vmin, vmax=self.vmax) + self.vmin = colormap_labels[0] + self.vmax = colormap_labels[-1] + self.colormap = LinearColormap(colors=colors, index=colormap_labels, vmin=self.vmin, vmax=self.vmax) class VectorTileLayer(Layer): From 373f5d9b8816892d50080cd9fe009a9f43e89f1b Mon Sep 17 00:00:00 2001 From: Florence Haudin Date: Wed, 10 Aug 2022 16:34:30 +0200 Subject: [PATCH 11/13] Sort the gradient to be compatible with the colormap treating with ordered colormap_labels. --- examples/Heatmap_with_colormap.ipynb | 2 +- ipyleaflet/leaflet.py | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/examples/Heatmap_with_colormap.ipynb b/examples/Heatmap_with_colormap.ipynb index 4d29c73e9..926805f1e 100644 --- a/examples/Heatmap_with_colormap.ipynb +++ b/examples/Heatmap_with_colormap.ipynb @@ -50,7 +50,7 @@ "outputs": [], "source": [ "m = ipyleaflet.Map(center=[0, 0], zoom=2)\n", - "heat = ipyleaflet.Heatmap(locations=create_random_data(1000), radius=20, blur=10, gradient={0.1 : 'orange', 0.2 : 'red', 1.0 :'black'})\n", + "heat = ipyleaflet.Heatmap(locations=create_random_data(1000), radius=20, blur=10, gradient={1.0: 'black', 0.2 : 'red', 0.1 : 'orange'})\n", "colormap_control = ipyleaflet.ColormapControl(\n", " caption='Intensity',\n", " colormap=heat.colormap,\n", diff --git a/ipyleaflet/leaflet.py b/ipyleaflet/leaflet.py index f51b6496a..1eeb2e2ad 100644 --- a/ipyleaflet/leaflet.py +++ b/ipyleaflet/leaflet.py @@ -820,7 +820,8 @@ class Heatmap(RasterLayer): max = Float(1.0).tag(sync=True, o=True) radius = Float(25.0).tag(sync=True, o=True) blur = Float(15.0).tag(sync=True, o=True) - gradient = Dict({0.4: 'blue', 0.6: 'cyan', 0.7: 'lime', 0.8: 'yellow', 1.0: 'red'}).tag(sync=True, o=True) + #gradient = Dict({0.4: 'blue', 0.6: 'cyan', 0.7: 'lime', 0.8: 'yellow', 1.0: 'red'}).tag(sync=True, o=True) + gradient = Dict({ 0.8: 'yellow', 0.6: 'cyan', 0.4: 'blue', 0.7: 'lime', 1.0: 'red'}).tag(sync=True, o=True) def __init__(self, **kwargs): super(Heatmap, self).__init__(**kwargs) @@ -831,8 +832,12 @@ def _updata_data(self, change): self.data = self._get_data() def _get_data(self): - colormap_labels = list(self.gradient.keys()) - colors = list(self.gradient.values()) + sorted_gradient = {} + sorted_keys = sorted(self.gradient.keys()) + for key in sorted_keys: + sorted_gradient[key] = self.gradient[key] + colormap_labels = list(sorted_gradient.keys()) + colors = list(sorted_gradient.values()) self.vmin = colormap_labels[0] self.vmax = colormap_labels[-1] self.colormap = LinearColormap(colors=colors, index=colormap_labels, vmin=self.vmin, vmax=self.vmax) From ec2e2a81a666313c63389f1cb45460e8dee5db3f Mon Sep 17 00:00:00 2001 From: HaudinFlorence <99649086+HaudinFlorence@users.noreply.github.com> Date: Wed, 10 Aug 2022 16:48:11 +0200 Subject: [PATCH 12/13] Update ipyleaflet/leaflet.py Co-authored-by: David Brochart --- ipyleaflet/leaflet.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/ipyleaflet/leaflet.py b/ipyleaflet/leaflet.py index 1eeb2e2ad..1ffd92647 100644 --- a/ipyleaflet/leaflet.py +++ b/ipyleaflet/leaflet.py @@ -832,10 +832,7 @@ def _updata_data(self, change): self.data = self._get_data() def _get_data(self): - sorted_gradient = {} - sorted_keys = sorted(self.gradient.keys()) - for key in sorted_keys: - sorted_gradient[key] = self.gradient[key] + sorted_gradient = dict(sorted(self.gradient.items())) colormap_labels = list(sorted_gradient.keys()) colors = list(sorted_gradient.values()) self.vmin = colormap_labels[0] From f6f10a5f8be784d845da32997af97c80cc979f2c Mon Sep 17 00:00:00 2001 From: Florence Haudin Date: Wed, 10 Aug 2022 16:53:11 +0200 Subject: [PATCH 13/13] Remove comment and unsorted gradient and fix flake8 issue. --- examples/Subitems.ipynb | 99 +++++++++++++++++++++++++++++++++++++++++ ipyleaflet/leaflet.py | 3 +- 2 files changed, 100 insertions(+), 2 deletions(-) create mode 100644 examples/Subitems.ipynb diff --git a/examples/Subitems.ipynb b/examples/Subitems.ipynb new file mode 100644 index 000000000..d227de6af --- /dev/null +++ b/examples/Subitems.ipynb @@ -0,0 +1,99 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "import ipyleaflet\n", + "import json\n", + "import pandas as pd\n", + "from ipywidgets import link, FloatSlider\n", + "from branca.colormap import linear\n", + "import random\n", + "\n", + "center = (43, -100)\n", + "zoom = 4\n", + "geo_json_data = json.load(open(\"us-states.json\"))\n", + "m = ipyleaflet.Map(center=center, zoom=zoom)\n", + "unemployment = pd.read_csv(\"US_Unemployment_Oct2012.csv\")\n", + "unemployment = dict(\n", + " zip(unemployment[\"State\"].tolist(), unemployment[\"Unemployment\"].tolist())\n", + ")\n", + "\n", + "colormap = linear.YlOrRd_04\n", + "marker = ipyleaflet.Marker(location=center, draggable=False)\n", + "\n", + "layer = ipyleaflet.Choropleth(\n", + " caption ='Unemployment rate',\n", + " geo_data=geo_json_data,\n", + " choro_data=unemployment,\n", + " colormap=linear.YlOrRd_04,\n", + " style={\"fillOpacity\": 0.8, \"dashArray\": \"5, 5\"},\n", + " #subitems= []\n", + ")\n", + "\n", + "m.add(layer)\n", + "print('layer.subitems', layer.subitems)\n", + "m\n" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "m.remove(layer.subitems)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "print('layer.subitems', layer.subitems)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "colormap_control = ipyleaflet.ColormapControl(\n", + " caption='Unemployment rate',\n", + " colormap=colormap,\n", + " value_min=layer.value_min,\n", + " value_max=layer.value_max,\n", + " position='topright',\n", + " transparent_bg=True\n", + ")\n", + "\n" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.13" + } + }, + "nbformat": 4, + "nbformat_minor": 4 +} diff --git a/ipyleaflet/leaflet.py b/ipyleaflet/leaflet.py index 1ffd92647..301345fd7 100644 --- a/ipyleaflet/leaflet.py +++ b/ipyleaflet/leaflet.py @@ -820,8 +820,7 @@ class Heatmap(RasterLayer): max = Float(1.0).tag(sync=True, o=True) radius = Float(25.0).tag(sync=True, o=True) blur = Float(15.0).tag(sync=True, o=True) - #gradient = Dict({0.4: 'blue', 0.6: 'cyan', 0.7: 'lime', 0.8: 'yellow', 1.0: 'red'}).tag(sync=True, o=True) - gradient = Dict({ 0.8: 'yellow', 0.6: 'cyan', 0.4: 'blue', 0.7: 'lime', 1.0: 'red'}).tag(sync=True, o=True) + gradient = Dict({0.4: 'blue', 0.6: 'cyan', 0.7: 'lime', 0.8: 'yellow', 1.0: 'red'}).tag(sync=True, o=True) def __init__(self, **kwargs): super(Heatmap, self).__init__(**kwargs)