So I wanted to rescale color 3D plot with a more agreeable set of values. Octave handles this, but I thought I'd write up how because it isn't an everyday task and I'm sure I'll forget how I did it.
Here's some data plotted with the default colormap:
The plot is fine but the wide range of color was subjectively implying more curvature in the data than I meant to. Of course that's all subjective but the data was supposed to make a point and the colormap was working against it.
Here's a 3D view that makes my point better, but 3D views on flat surfaces are harder to interpret; for example, the diagonal "valley" of low spots gets a little lost:
So I built my own lowest to highest Red-Yellow-Green colormap and applied it; here's how.
n_levels = (10-7)/0.1 + 1; % numbers of interest range from 7 to 10
% build RGB channels from red to yellow:
red2yellow_chRed = linspace(1, 1, n_levels/2);
red2yellow_chGreen = linspace(0, 1, n_levels/2);
red2yellow_chBlue = linspace(0, 0, n_levels/2);
% build RGB channels from yellow to green:
yellow2green_chRed = linspace(1, 0, n_levels/2);yellow2green_chGreen = linspace(1, 1, n_levels/2);
yellow2green_chBlue = linspace(0, 0, n_levels/2);
% create the colormap by stacking and concatenating the channel vectors::
RYG_colormap = [ ...[red2yellow_chRed'; yellow2green_chRed'] ...
[red2yellow_chGreen'; yellow2green_chGreen'] ...
[red2yellow_chBlue'; yellow2green_chBlue'] ...
];
% set the colormap
colormap(RYG_colormap);The plot automatically updates and helps support my point that there's not so much curvature in the data.
If you don't like it, you can easily switch back:
colormap("default");
Or if black and white is better for you, there's a predefined grayscale map:
colormap(gray);
There you go. Colormaps. Happy (r)Octave-ing!
- nzvyyx
No comments:
Post a Comment