23 colormaps
Creating colormaps with a single line of code
Uncomment the following line to install leafmap if needed.
In [1]:
Copied!
# !pip install leafmap
# !pip install leafmap
This notebook requires the ipyleaflet plotting backend. Folium is not supported.
In [2]:
Copied!
from leafmap import leafmap
import leafmap.colormaps as cm
from leafmap import leafmap
import leafmap.colormaps as cm
Color palette for DEM data.
In [3]:
Copied!
cm.palettes.dem
cm.palettes.dem
Out[3]:
('006633', 'E5FFCC', '662A00', 'D8D8D8', 'F5F5F5')
Show the DEM palette.
In [4]:
Copied!
cm.plot_colormap(colors=cm.palettes.dem, axis_off=True)
cm.plot_colormap(colors=cm.palettes.dem, axis_off=True)
Color palette for NDVI data.
In [5]:
Copied!
cm.palettes.ndvi
cm.palettes.ndvi
Out[5]:
('FFFFFF', 'CE7E45', 'DF923D', 'F1B555', 'FCD163', '99B718', '74A901', '66A000', '529400', '3E8601', '207401', '056201', '004C00', '023B01', '012E01', '011D01', '011301')
Show the NDVI palette.
In [6]:
Copied!
cm.plot_colormap(colors=cm.palettes.ndvi)
cm.plot_colormap(colors=cm.palettes.ndvi)
Specify the number of classes for a palette.
In [7]:
Copied!
cm.get_palette('terrain', n_class=8)
cm.get_palette('terrain', n_class=8)
Out[7]:
['333399', '0294fa', '24d36d', 'b6f08a', 'dbd085', '92735e', 'b6a29d', 'ffffff']
Show the terrain palette with 8 classes.
In [8]:
Copied!
cm.plot_colormap(colors=cm.get_palette('terrain', n_class=8))
cm.plot_colormap(colors=cm.get_palette('terrain', n_class=8))
Create a palette with custom colors, label, and font size.
In [9]:
Copied!
cm.plot_colormap(colors=["red", "green", "blue"], label="Temperature", font_size=12)
cm.plot_colormap(colors=["red", "green", "blue"], label="Temperature", font_size=12)
Create a discrete color palette.
In [10]:
Copied!
cm.plot_colormap(
colors=["red", "green", "blue"], discrete=True, label="Temperature", font_size=12
)
cm.plot_colormap(
colors=["red", "green", "blue"], discrete=True, label="Temperature", font_size=12
)
Specify the width and height for the palette.
In [11]:
Copied!
cm.plot_colormap(
'terrain',
label="Elevation",
width=8.0,
height=0.4,
orientation='horizontal',
vmin=0,
vmax=1000,
)
cm.plot_colormap(
'terrain',
label="Elevation",
width=8.0,
height=0.4,
orientation='horizontal',
vmin=0,
vmax=1000,
)
Change the orentation of the colormap to be vertical.
In [12]:
Copied!
cm.plot_colormap(
'terrain',
label="Elevation",
width=0.4,
height=4,
orientation='vertical',
vmin=0,
vmax=1000,
)
cm.plot_colormap(
'terrain',
label="Elevation",
width=0.4,
height=4,
orientation='vertical',
vmin=0,
vmax=1000,
)
Add a horizontal colorbar to an interactive map.
In [13]:
Copied!
m = leafmap.Map()
m.add_basemap("OpenTopoMap")
m.add_colormap(
'terrain',
label="Elevation",
width=8.0,
height=0.4,
orientation='horizontal',
vmin=0,
vmax=4000,
)
m
m = leafmap.Map()
m.add_basemap("OpenTopoMap")
m.add_colormap(
'terrain',
label="Elevation",
width=8.0,
height=0.4,
orientation='horizontal',
vmin=0,
vmax=4000,
)
m
Add a vertical colorbar to an interactive map.
In [14]:
Copied!
m = leafmap.Map()
m.add_basemap("OpenTopoMap")
m.add_colormap(
'terrain',
label="Elevation",
width=0.4,
height=4,
orientation='vertical',
vmin=0,
vmax=4000,
)
m
m = leafmap.Map()
m.add_basemap("OpenTopoMap")
m.add_colormap(
'terrain',
label="Elevation",
width=0.4,
height=4,
orientation='vertical',
vmin=0,
vmax=4000,
)
m
Show all available colormaps.
In [15]:
Copied!
cm.plot_colormaps(width=12, height=0.4)
cm.plot_colormaps(width=12, height=0.4)
Last update:
2022-03-14