Quick Start
This guide walks through previewing a colormap, checking it, saving it, and exporting it. The same steps work from Python.
Preview a Colormap
Section titled “Preview a Colormap”The show command renders a colormap preview directly in your terminal:
# Show a built-in presetpalettize show viridis
# Show a custom gradientpalettize show --colors "midnightblue,orange,gold"
# Or use uvx to run without installinguvx palettize show viridisYou can adjust the preview, reverse it, or write an image:
palettize show viridis --width 80 --height 3palettize show viridis --steps 7 --hexpalettize show viridis --reverse -o preview.pngCheck a Colormap
Section titled “Check a Colormap”analyze reports lightness, perceptual step size, and how the map looks under protanopia, deuteranopia, and tritanopia:
palettize analyze cividispalettize analyze jet --strict # non-zero exit when problems are foundExport a Colormap
Section titled “Export a Colormap”The create command exports colormaps to various file formats:
# Export viridis to GDAL format with a data domain of 0-255palettize create viridis --format gdal --output viridis.txt --domain 0,255Custom Colors
Section titled “Custom Colors”Instead of using a preset, you can define your own colors:
palettize create --colors "blue,white,red" --format gdal --output bwr.txt --domain 0,100Multiple Formats
Section titled “Multiple Formats”Export to multiple formats at once using the {name}, {format}, and {ext} placeholders:
palettize create viridis --format gdal,qgis,mapgl \ --output "output/{name}_{format}.{ext}" \ --domain 0,255 \ --steps 11This creates:
output/viridis_gdal.txtoutput/viridis_qgis.xmloutput/viridis_mapgl.json
Save and Reuse
Section titled “Save and Reuse”--save writes a JSON file. Any command that takes a preset also accepts that file:
palettize create viridis --cut 0.2,0.8 --reverse --save my-map.jsonpalettize show my-map.jsonpalettize create my-map.json -f css -o theme.cssFind a Preset or a Format
Section titled “Find a Preset or a Format”palettize list presets --search blue --category sequentialpalettize formatspalettize formats gdalUsing from Python
Section titled “Using from Python”Palettize can also be used as a library:
from palettize import create_colormap, get_scaler_by_name
# Create a colormap from a presetcmap = 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 colorscmap2 = create_colormap( colors=["#0000ff", "white", "#ff0000"], name="BlueWhiteRed")
# Use a scaler to map data values to colorsscaler = get_scaler_by_name("linear", domain_min=0, domain_max=100)color_at_50 = cmap2.apply_scaler(50, scaler) # Color at the midpointNext Steps
Section titled “Next Steps”- Learn about all CLI commands
- Explore the Python API
- See all Export Formats
- Understand Color Interpolation
- Transform and save colormaps