From GDL Wiki
Jump to: navigation, search

This method of setting up a grayscale colorbar (a legend for the fill levels of a contour plot) will make a horizontal colorbar by default.

mincolor = min(zvalues)
maxcolor = max(zvalues)
n_colors = 11
colorlevels = mincolor + Findgen(n_colors)*(maxcolor-mincolor)/n_colors
Hcolorbar = [[colorlevels],[colorlevels]]

For a vertical colorbar, transpose the horizontal colorbar.

Vcolorbar = transpose(Hcolorbar)

Plot the data. Use the POSITION keyword to move the main plot to the left, to make room for the colorbar on the right.


Plot the colorbar. The XSTYLE=4 keyword will suppress the dummy tickmarks on the x-axis. The xtickname="(A1)" keyword will suppress the dummy values on the x-axis. Use the NOERASE keyword instead of !P.MULTI.

 & xstyle=4,xtickname="(A1)",ystyle=1,/fill,/noerase