Color tables in h5topng

From AbInitio

Revision as of 22:19, 22 May 2008; Stevenj (Talk | contribs)
(diff) ←Older revision | Current revision | Newer revision→ (diff)
Jump to: navigation, search

The h5topng utility program contains a number of built-in color tables that you can use for plotting data. These color tables are listed below, in some cases with notes about where they came from or suggested usage.

(My own favorites are bluered and dkbluered for signed data, and gray or hot for unsigned/nonnegative data.)

Color tables

The color scales that I most commonly use are the following five:

Name of color table Color table image Comments
gray simple black-to-white grayscale color bar
bluered blue-white-red colorbar, useful for signed data in conjunction with -Z option to make white=0
dkbluered dark blue-white-red colorbar, useful for signed data in conjunction with -Z option to make white=0; similar to bluered but shows a bit more dynamic range for the maxima/minima by darkening at the ends
hot black-red-yellow-white color map, useful for nonnegative "intensity" data — based on colormap of the same name in Matlab, loosely resembles color of heated object at increasing temperatures
yarg simple white-to-black grayscale color bar (the reverse of gray, and equivalent to using -gray or gray with -r); this is useful to make contour-like overlays with the -A option

The remaining color scales, mostly based on the corresponding colormaps of the same name in Matlab, are:

Name of color table Color table image Comments
autumn red-orange-yellow color map; based on colormap of the same name in Matlab
bone nearly grayscale (blackish to whitish) color map with a tinge of blue; based on colormap of the same name in Matlab, which suggests using it to add an "electronic" look to grayscale images
colorcube enhanced color-cube color map; based on colormap of the same name in Matlab, basically designed to fill the RGB color space with an emphasis on a few pure colors
cool cyan-magenta color map; based on colormap of the same name in Matlab
copper black-copper color map; based on colormap of the same name in Matlab
flag alternating red/white/blue/black color map; based on colormap of the same name in Matlab
green white-green color map; useful for translucent overlays with -A
hsv red-yellow-green-cyan-blue-pink-magenta color map formed by changing the hue component in the HSV color space; based on colormap of the same name in Matlab, who recommend it for used in plotting periodic data (that is, in which the maximum magnitude and the minimum magnitude are equivalent)
jet blue-cyan-yellow-red color map (a variant of hsv; based on colormap of the same name in Matlab, who based it on a fluid-jet simulation by NCSA
lines oscillating color map; based on colormap of the same name in Matlab (based on the Matlab plot-line colors)
pink pastel black-pink-white color map; based on colormap of the same name in Matlab, used for w:Sepia tone colorization
prism repeating red-yellow-green-blue-purple-...-green color map; based on colormap of the same name in Matlab
spring magenta-yellow color map; based on colormap of the same name in Matlab
summer green-yellow color map; based on colormap of the same name in Matlab
vga Windows 4-bit color map; based on colormap of the same name in Matlab
winter blue-green color map; based on colormap of the same name in Matlab
yellow white-yellow color map; useful for translucent overlays with -A

Using the color tables in h5topng

To use a given color table in h5topng, simply use the -c option. For example, to use the hot color table, you might do:

h5topng -c hot foobar.h5

To apply the bluered or dkbluered tables to signed (positive and negative) data, you usually want to "center" the color table so that the middle (white) corresponds to zero data. You can do this with the -Z option, as in:

h5topng -Zc bluered foobar.h5

By default, h5topng scales the color table so that the ends correspond to the minimum and maximum of the data. (In the case of -Z, the data is centered so that one end of the color table corresponds to the maximum magnitude.) However, in some cases you want to "saturate" the color table to emphasize small values, so that all values above some maximum (or below some minimum) are simply assigned to the maximum (or minimum) color in the table. You can do this using the -M (or -m) option(s). For example, to set the minimum at 0 and the maximum at 0.0001, you might do:

h5topng -m 0 -M 0.0001 -c hot foobar.h5

Another useful option is -r, which reverses the order of the color table (e.g. to make blue positive and red negative).

See the Unix man page for h5topng for more information.

Making a colorbar image

If you want to use the h5topng plot in a publication, often you will want to give a colorbar showing the scale of values. h5topng itself does not add axis labels or colorbars, but you can put these together in an external drawing program like Inkscape. To create a PNG image of the color scale, a simple trick is the following:

echo "0 1" | h5fromtxt colorbar.h5
h5topng -c hot -X 256 -Y 50 colorbar.h5

The first command creates an HDF5 file with the numbers 0 and 1 using the h5fromtxt utility, and the second creates a 256×50 image of the color scale (here for hot). You can, of course, resize the image or change color scales as needed.

You will have to manually label the minimum and maximum values when you import the color scale into your drawing program. If you don't know these values, you can make h5topng print them out by passing the -v (verbose) option when generating the image from your data.

Personal tools