Skip to content

Quick Start

This guide will walk you through the basic usage of Palettize. By the end, you’ll know how to preview colormaps, create exports, and use Palettize from Python.

The show command renders a colormap preview directly in your terminal:

Terminal window
# Show a built-in preset
palettize show viridis
# Show a custom gradient
palettize show --colors "midnightblue,orange,gold"

You can adjust the preview size:

Terminal window
palettize show viridis --width 80 --height 3

The create command exports colormaps to various file formats:

Terminal window
# Export viridis to GDAL format with a data domain of 0-255
palettize create viridis --format gdal --output viridis.txt --domain 0,255

Instead of using a preset, you can define your own colors:

Terminal window
palettize create --colors "blue,white,red" --format gdal --output bwr.txt --domain 0,100

Export to multiple formats at once using the {name}, {format}, and {ext} placeholders:

Terminal window
palettize create viridis --format gdal,qgis,mapgl \
--output "output/{name}_{format}.{ext}" \
--domain 0,255 \
--steps 11

This creates:

  • output/viridis_gdal.txt
  • output/viridis_qgis.xml
  • output/viridis_mapgl.json

See what presets and exporters are available:

Terminal window
# List all colormap presets
palettize list presets
# List all export formats
palettize list exporters

Palettize can also be used as a library:

from palettize import create_colormap, get_scaler_by_name
# Create a colormap from a preset
cmap = create_colormap(preset="viridis", name="Viridis")
# Get a color at a specific position (0-1)
hex_color = cmap.get_color(0.5) # Returns "#21918c"
rgb = cmap.get_color(0.5, output_format="rgb_tuple") # Returns (33, 145, 140)
# Create from custom colors
cmap2 = create_colormap(
colors=["#0000ff", "white", "#ff0000"],
name="BlueWhiteRed"
)
# Use a scaler to map data values to colors
scaler = get_scaler_by_name("linear", domain_min=0, domain_max=100)
color_at_50 = cmap2.apply_scaler(50, scaler) # Color at the midpoint