Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

polcmap

Create colormap appropriate to political regions

Syntax

polcmap
polcmap(ncolors)
polcmap(ncolors,maxsat)
polcmap(ncolors,huelimits,saturationlimits,valuelimits)
cmap = polcmap(___)

Description

polcmap applies a random, muted colormap to the current figure. The size of the colormap is the same as the existing colormap.

example

polcmap(ncolors) creates a colormap with the specified number of colors.

polcmap(ncolors,maxsat) controls the maximum saturation of the colors.

polcmap(ncolors,huelimits,saturationlimits,valuelimits) controls the hue, saturation, and value of the colors. polcmap randomly selects values within the limit vectors. These are two-element vectors of the form [min max]. Valid values range from 0 to 1. As the hue varies from 0 to 1, the resulting color varies from red, through yellow, green, cyan, blue, and magenta, back to red. When the saturation is 0, the colors are unsaturated; they are simply shades of gray. When the saturation is 1, the colors are fully saturated; they contain no white component. As the value varies from 0 to 1, the brightness increases.

cmap = polcmap(___) returns the colormap without applying it to the figure.

Examples

collapse all

Create an empty map axes with a Lambert Conformal Conic projection and map limits covering Texas.

figure;
usamap('texas')

Read vector features, such as state boundaries, from a shapefile.

states = shaperead('usastatelo.shp','UseGeoCoords',true);

Define the colors you want to apply to the shapes (states) in a symbol specification. Use polcmap to create a color map the same size as the number of elements in the states array. polcmap creates a palette of muted colors.

faceColors = makesymbolspec('Polygon',...
     {'INDEX', [1 numel(states)], 'FaceColor', ...
      polcmap(numel(states))});

Display the map using the symbol specificaton to color the patches (states) in the map. The colors you obtain for this example can vary each time you run this example because polcmap computes them randomly.

  geoshow(states, 'DisplayType', 'polygon', 'SymbolSpec', faceColors)

Input Arguments

collapse all

Number of colors in the color map, specified as a numeric scalar.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical

Maximum saturation of colors, specified as a numeric scalar. Larger maximum saturation values produce brighter, more saturated colors.

Data Types: single | double | logical | char

Color range limits, specified as a two-element vector of the form [min max]. Values range from 0 to 1.0. As the hue varies from 0 to 1, the resulting color varies from red, through yellow, green, cyan, blue, and magenta, back to red.

Data Types: single | double

Color saturation limits, specified as a two-element vector of the form [min max]. Values range from 0 to 1.0. When the saturation is 0, the colors are unsaturated; they are simply shades of gray. When the saturation is 1, the colors are fully saturated; they contain no white component.

Data Types: single | double

Brightness of colors, specified as a two-element vector of the form [min max]. Values range from 0 to 1.0. As the value varies from 0 to 1, the brightness increases.

Data Types: single | double

Output Arguments

collapse all

Colormap, returned as an m-by-3 numeric array of class double or class single, depending on the type of the input.

Tips

  • You cannot use polcmap to alter the colors of displayed patches drawn by geoshow or mapshow. The patches must have been rendered by displaym. However, you can color patches using polcmap when you call geoshow or mapshow (see Color Patches with SymbolSpec Created Using polcmap).

See Also

|

Introduced before R2006a

Was this topic helpful?