Skip to content

Quick Start

This guide walks through previewing a colormap, checking it, saving it, and exporting it. The same steps work 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"
# Or use uvx to run without installing
uvx palettize show viridis

You can adjust the preview, reverse it, or write an image:

Terminal window
palettize show viridis --width 80 --height 3
palettize show viridis --steps 7 --hex
palettize show viridis --reverse -o preview.png

analyze reports lightness, perceptual step size, and how the map looks under protanopia, deuteranopia, and tritanopia:

Terminal window
palettize analyze cividis
palettize analyze jet --strict # non-zero exit when problems are found

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

--save writes a JSON file. Any command that takes a preset also accepts that file:

Terminal window
palettize create viridis --cut 0.2,0.8 --reverse --save my-map.json
palettize show my-map.json
palettize create my-map.json -f css -o theme.css
Terminal window
palettize list presets --search blue --category sequential
palettize formats
palettize formats gdal

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 "#21918d"
rgb = cmap.get_color(0.5, output_format="rgb_tuple") # Returns (33, 145, 141)
# 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