./
pp_cmap.pro
Routines
top source pp_cmap
result = pp_cmap(nc [, lct=lct] [, grey=grey] [, hls=hls])
Returns a colormap with nc saturated colors equally spaced in hue, plus black, white and one grey.
Return value
A (3,(nc+3)) array, where each row contains the HLS or RGB values for each color. The first color is black, the last is white, the one before last is grey, and the equally spaced saturated colors lie in between, in hue order.
Parameters
- nc in required
Number of equally spaced saturated colors to make.
Keywords
- lct in optional default=0
If set, the colormap created is loaded with tvlct.
- grey in optional default=0.5d0
The intensity of the grey color to make.
- hls in optional default=0
If set, the colors returned are in HLS space, instead of RGB space.
Examples
Make a plot with pure black, red, green and blue lines:
cmap=pp_cmap(3)
for i=0,3 do iplot,randomu(seed,10),color=cmap[*,i],over=(i ne 0),thick=2.
cmap=pp_cmap(6)
for i=0,6 do iplot,randomu(seed,10),color=cmap[*,i],over=(i ne 0),thick=2.
cmap=pp_cmap(3)
olddev=!d.name ;keep a copy of the current device name
set_plot,'ps'
device,filename='pp_cmap.eps',/encapsulated,/color,decomposed=0
tvlct,old1,old2,old3,/get ;keep a copy of the current colormap
tvlct,cmap[0,*],cmap[1,*],cmap[2,*] ;change the colormap
plot,[0d0,9d0],[0d0,1d0],/nodata
for i=0,3 do oplot,randomu(seed,10),color=i,thick=2.
tvlct,old1,old2,old3 ;restore the old colormap
device,/close
set_plot,olddev ;restore the old device name
cmap=pp_cmap(3)
olddev=!d.name ;keep a copy of the current device name
set_plot,'ps'
device,filename='pp_cmap.eps',/encapsulated,/color,decomposed=1
plot,[0d0,9d0],[0d0,1d0],/nodata
for i=0,3 do oplot,randomu(seed,10),color=cmap[0,i]+cmap[1,i]*2L^8+cmap[2,i]*2L^16,thick=2.
device,/close
set_plot,olddev ;restore the old device name
Author information
- Author:
Paulo Penteado (pp.penteado@gmail.com), Dec/2009
Statistics
Lines: | 20 lines |
Cyclomatic complexity: | 5 |
Modified cyclomatic complexity: | 5 |
File attributes
Modification date: | Wed Jun 29 22:15:28 2016 |
Lines: | 20 |
Docformat: | rst rst |