% Create 13-level blue/red diverging color map: level = 13; n = ceil(level/2); cmap1 = [linspace(1, 1, n); linspace(0, 1, n); linspace(0, 1, n)]'; cmap2 = [linspace(1, 0, n); linspace(1, 0, n); linspace(1, 1, n)]'; cmap = [cmap1; cmap2(2:end, :)]; imagesc(peaks(500)); colormap(vivid(cmap)); caxis([-8 8]); colorbarNotice how vivid it looks! vivid also has additional options to change the level of gradients. Less vivid:
colormap(vivid(cmap, [.4, .6]));More vivid:
colormap(vivid(cmap, [0, 1]));You can also get the regular colormap behavior:
colormap(vivid(cmap, [.5 .5]));More on Colormaps As I was writing this post, I learned quite a bit about colormaps. MATLAB has a set of standard colormaps described here. There are a few File Exchange entries that create additional colormaps, such as cbrewer, othercolor, and Color Palette Tables. There are also colormaps that would look nice when printed on a grayscale printer - Lab color scale and colorGray. I also found a couple of entries that would have helped me with creating the blue/red diverging colormap - bluewhitered and makeColorMap. Comments Check out all the File Exchange entries on colormaps! If you have your favorite colormap, let us know here or try Joseph's vivid and leave a comment for him.
要发表评论，请点击 此处 登录到您的 MathWorks 帐户或创建一个新帐户。