Color tables in h5topng

From AbInitio

Revision as of 21:32, 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

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