Madhavan Bomidi writes:
> I have a data matrix with 99 columns and 86400 rows (each row
represents time in seconds). The whole of the data matrix is arranged
with only 5 numbers = [-9, 1, 2, 3, 4]. I wanted to make a color bar
with 4 colors = ['DARK RED','RED','SKY BLUE', 'BLUE'] representing
numbers [1, 2, 3, 4] respectively and -9 represents a missing value
(assigned 'WHITE' color)
>
> Below are my lines in the code for synthetic data:
>
> time=LINDGEN(86400) ; in seconds
>
> tmp_data=REPMAT([-9,1,2,3,4],20,86400)
> data=tmp_data[0:98,*]
>
> missingIndices=WHERE(data EQ -9, missingCount)
> IF missingCount GT 0 THEN data[missingIndices]=0
The following command is unnecessary.
> img=BytScl(data,MIN=0,MAX=4,/NAN)
It probably doesn't hurt anything, but you could do just as well with
this command:
img = Byte(data)
> TVLCT, cgColor('WHITE',/Triple),0 ; Background color
> TVLCT, cgColor(['DARK RED','RED','SKY BLUE','BLUE'],/Triple),1
>
> ???
> ???
>
> Now my problem is ... I want X-axis with time, Y-axis with data column indices (i.e., indgen(99)) where I wanted to place colored dots (basing on the colorbar) for each of the data point column wise for all the time points. Can anyone suggest me how shall I proceed after the above steps in simplest way?
You don't want colored dots. Putting them on your plot will take weeks,
if not longer. And, unless you are making your plot the size of a
building, you wouldn't see individual dots anyway. :-)
Try this:
time=LINDGEN(86400) ; in seconds
tmp_data=REPMAT([-9,1,2,3,4],20,86400)
data=tmp_data[0:98,*]
missingIndices=WHERE(data EQ -9, missingCount)
IF missingCount GT 0 THEN data[missingIndices]=0
img=Byte(data)
TVLCT, cgColor('WHITE',/Triple),0 ; Background color
TVLCT, cgColor(['DARK RED','RED','SKY BLUE','BLUE'],/Triple),1
cgimage, Transpose(data), /axes, axkeyword={xtitle:'Time'}
END
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
|