Seamlessly combine two colormaps into one — for topography, thresholds, or any visualization that needs a split color scheme.
Stitched Colorbars provides a simple utility to create a new colormap by stitching two existing colormaps at a configurable split point. Available for both MATLAB and Python (matplotlib).
Standard colormaps apply a single gradient across an entire data range. But many datasets have a meaningful boundary — sea level in topography, a pass/fail threshold, or a transition between regimes. Stitching colormaps lets you:
- Use distinct color schemes above and below a critical value
- Combine any two colormaps from libraries like cmocean, matplotlib, or custom palettes
- Control the exact split point to match your data's natural boundary
Using cmocean('deep') below sea level and cmocean('topo') (upper half) above.
Using gray and jet to distinguish features above and below a threshold.
The Python implementation is located in the python/ directory.
Copy the python/stitched_colorbars/ folder into your project.
from stitched_colorbars import stitch_colormaps
import matplotlib.pyplot as plt
# Stitch two colormaps at 40% (0.4)
# You can pass names ("Blues", "Reds") or distinct objects
combined = stitch_colormaps("Blues", "Reds", 0.4)
plt.imshow(data, cmap=combined)See the full example script: python/examples/stitched_colormaps_example.py
The MATLAB implementation is located in the matlab/ directory.
Add the matlab/colormaps/ folder to your path:
addpath(genpath('matlab/colormaps'));
% Define split point (0-100)
stich_point = 40;
% Stitch two colormaps
cmap = stiched_colormap(flipud(cmocean('deep')), elevation(), stich_point);
colormap(cmap);See the example script: matlab/stiched_colormaps_example.m
Creates a new colormap by combining two colormaps at the given split point.
| Parameter | Type | Description |
|---|---|---|
c1 |
str / array / Colormap | First colormap (lower portion) |
c2 |
str / array / Colormap | Second colormap (upper portion) |
stich_point |
float (0.0–1.0) | Split position (e.g. 0.3 = 30% c1, 70% c2) |
Returns: A ListedColormap ready to use with matplotlib.
Resamples a colormap to a different number of colors, optionally using only a sub-range.
| Parameter | Type | Description |
|---|---|---|
cmap |
str / array / Colormap | Input colormap |
num_colors |
int | Number of output colors |
vmin |
float (0–1) | Start of the range (default 0) |
vmax |
float (0–1) | End of the range (default 1) |
├── python/
│ ├── stitched_colorbars/ # Core Python package
│ └── examples/ # Example scripts & images
│
├── matlab/
│ ├── colormaps/ # MATLAB functions
│ └── examples/ # MATLAB examples
│
└── README.md
Check out my other projects at alexisgomel.com/projects.
This project is licensed under the GNU General Public License v3.0.

