Skip to main content

7.5) Adding A Colour Bar


Generally it is useful to know what values equate to what colours in the contour plot. We can do this by adding a colour bar, by far the easiest way to do this is to use the "colorbar" procedure, which has been written by David Flanning IDL Coyote. Copy the procedure colorbar.pro to your IDL directory.

Now, before we add a colour bar, we need to make some space at the top of our plot. We can do this by using the "position" keyword in the call to map_set:

map_set, /mercator, limit=[0,-30,40,40], position=[0.15,0.15,0.9,0.8]

Position can be used to position any graphics such as a standard plot. It is a 4 element vector that gives the coordinates of the lower left and upper right corners of the plot within the window [x0,y0,x1,y1]. The coordinates are expressed in normalised units from 0 to 1.

Next we plot our contour map:

contour, q(*,*,20,0), lon, lat, levels=levs, c_labels=labels, /fill, /overplot
map_continents

And now we add the colour bar:

colorbar, range=[min(levs),max(levs)], position=[0.15,0.88,0.9,0.93], format='(f9.3)', title='Water vmr'

Take a look at the description at the top of the colorbar procedure if you want to know what all the keywords are.