National Oceanic and
Atmospheric Administration
United States Department of Commerce

continuous colorbar

continuous colorbar

Question:

Is there a way to remove the the black lines in the colorbar of a shade or fill plot, so that I can get a smooth transition?

Example:

The default colorbar doesn't work well on plots that use many levels. The black lines between levels make it hard to see the colors.

default colorbar

The above plot shows the default colorbar, produced by these commands:

 ! Define a variable ranging from 0 to 6 ! and plot it in fine detail with the default colorbar yes? DEFINE axis/x=0:200:1 xax yes? DEFINE axis/y=0:100:1 yax yes? LET var=6*(X[GX=xax]+Y[GY=yax])/300 yes? FILL/LEV=(0,6,0.06)/TITLE="Default Colorbar" var

Solution:

The simplest solution is the newer option /KEY=continuous for the KEY qualifier for color plot commands (FILL, SHADE, and POLYGON).

 yes? SHADE/I=15/J=10/KEY=CONT I+J

 

We keep this FAQ in place, as it shows how one might further customize a color key. (See also the on-line demo ccbar_demo.html.) 

Look at the script ccbar.jnl. This is one of the scripts released with Ferret, so you can view it with:

 yes? GO/help ccbar.jnl

ccbar.jnl defines a viewport and fills that viewport with a shade plot of a variable that has the desired range of levels. Note that ccbar.jnl could easily be customized, for different size or style of labels, and so on.

The arguments of ccbar are as follows:

! GO ccbar x1 x2 y1 y2 v1 v2 dv orient palette

! x1 = x lo limit of rectangle for the colorbar! x2 = x hi limit of rectangle for the colorbar! y1 = y lo limit of rectangle for the colorbar! y2 = y hi limit of rectangle for the colorbar! v1 = lo value on colorbar ! v2 = hi value on colorbar! dv = delta value for clorbar axis!! orientation = v for vertical or h for horizontal, default v! palette to use, optional

Where the first four arguments define a rectangle, as a fraction of the entire plot page. This is equivalent to how DEFINE VIEWPORT works. Its qualifiers /XLIMITS=x1,x2 and /YLIMITS=y1,y2 allow the user to specify a portion of the graphics window as the viewport.

Here is a simple example that calls ccbar.jnl.

 ! Replot the variable defined above, but hold off on the colorbar.

 ! First SET VIEWPORT, so that the key can be added as a viewport 
 !
 yes? SET VIEW full      ! This holds the plot
 
 yes? FILL/LEV=(0,6,0.06)/TITLE="Continuous Colorbar Demo"/NOKEY var
 
 ! Plot the continuous colorbar, taking up the fraction of the window
 ! from  x=0.93 to 0.96, y=0.2 to 0.8, and showing levels from 0 to 6,
 ! with increments of 0.06.  Orient it vertically.
 
 yes? GO ccbar  0.93,0.96,  0.2,0.8,  0,6,0.06, v