IDL Colorbar generation question [message #49146] |
Mon, 03 July 2006 15:19  |
britneys
Messages: 3 Registered: July 2006
|
Junior Member |
|
|
Hi All,
I am attempting to add colorbars to my data plots. I have a set of
self-defined colors that are used in my routine, saved to the standard
R_CURR, G_CURR and B_CURR arrays. I had been trying to use either the
IDLgrColorbar_define program or David Fanning's colorbar_define.
Using IDLgrColorbar_define as prescribed:
oColorbar =OBJ_NEW("IDLgrColorbar", [R_CURR, G_CURR, B_CURR],
SHOW_AXIS=1, Title='values', HIDE=0)
The colorbar is nowhere to be found in my window. Have I missed an
element of the call?
Additionally, I am wondering two things about colorbar_define: 1) how
can I use my self-defined color vectors in this routine (or can I?) 2)
is there any change I should make so that the colorbar remains
high-quality in a ps-output?
Thanks in advance for any guidance, or suggestions of other ways I can
make an easy color bar. Earlier topics have been helpful to progress
but I've been unable to fix these specifics.
:)
|
|
|
Re: IDL Colorbar generation question [message #49220 is a reply to message #49146] |
Thu, 06 July 2006 09:16   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
britneys@ucla.edu writes:
> I do use direct graphics, whoops on the graphics object! This is how
> the window is called:
>
> SET_PLOT,PLATFORM
> !P.FONT=0
> DEVICE,DECOMPOSE=0,RETAIN=2
> !P.BACKGROUND=255 ;background color=white
> WINDOWCOUNT=0
> WINDOW,WINDOWCOUNT,xsize=XWIND,ysize=YWIND,title=VERSION
> ERASE
>
> Okay, so back to your colorbar routine, it will automatically use my
> self-defined color table? I used the following call:
>
> colorbar = Obj_New("COLORBAR", Range=[0,1000], Format='(I4)', $
> Title='Values')
> colorbar->SetProperty, Position=[0.1, 0.75, 0.9, 0.80], /Draw
> colorbar->Draw
>
> is this correct?
Yes, assuming you have loaded a 256-color color table before
this call, this will work perfectly.
> Also, when i output the file to a ps, the colorbar,
> instead of being a smooth color transition ends up as several boxes of
> different colors instead. Any ideas as to why this might occur?
You didn't set BITS_PER_PIXEL=8 in the PostScript device. :-)
Thus, you are only seeing 16 possible colors. I'd use PSCONFIG
to configure your PS device. Then this problem will be relegated
to the past forever.
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|
Re: IDL Colorbar generation question [message #49228 is a reply to message #49146] |
Wed, 05 July 2006 15:07   |
britneys
Messages: 3 Registered: July 2006
|
Junior Member |
|
|
Coyote wrote:
> Tell us what system you used to draw your plots, and we can advise
> you more sensibly.
>
I do use direct graphics, whoops on the graphics object! This is how
the window is called:
SET_PLOT,PLATFORM
!P.FONT=0
DEVICE,DECOMPOSE=0,RETAIN=2
!P.BACKGROUND=255 ;background color=white
WINDOWCOUNT=0
WINDOW,WINDOWCOUNT,xsize=XWIND,ysize=YWIND,title=VERSION
ERASE
Okay, so back to your colorbar routine, it will automatically use my
self-defined color table? I used the following call:
colorbar = Obj_New("COLORBAR", Range=[0,1000], Format='(I4)', $
Title='Values')
colorbar->SetProperty, Position=[0.1, 0.75, 0.9, 0.80], /Draw
colorbar->Draw
is this correct? Also, when i output the file to a ps, the colorbar,
instead of being a smooth color transition ends up as several boxes of
different colors instead. Any ideas as to why this might occur?
Thanks again!
|
|
|
Re: IDL Colorbar generation question [message #49241 is a reply to message #49146] |
Tue, 04 July 2006 02:15   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
britneys@ucla.edu writes:
> I am attempting to add colorbars to my data plots. I have a set of
> self-defined colors that are used in my routine, saved to the standard
> R_CURR, G_CURR and B_CURR arrays. I had been trying to use either the
> IDLgrColorbar_define program or David Fanning's colorbar_define.
>
> Using IDLgrColorbar_define as prescribed:
>
> oColorbar =OBJ_NEW("IDLgrColorbar", [R_CURR, G_CURR, B_CURR],
> SHOW_AXIS=1, Title='values', HIDE=0)
>
> The colorbar is nowhere to be found in my window. Have I missed an
> element of the call?
Humm. These two colorbar routines belong to two completely
different graphics systems in IDL. These systems cannot be
combined with one another. I *presume* you are using the
direct graphics system (PLOT, CONTOUR, SURFACE, etc.)
If so, you will NEVER see IDLgrColorbar in your window, since it
uses the object graphic system.
Tell us what system you used to draw your plots, and we can advise
you more sensibly.
> Additionally, I am wondering two things about colorbar_define: 1) how
> can I use my self-defined color vectors in this routine (or can I?) 2)
> is there any change I should make so that the colorbar remains
> high-quality in a ps-output?
If you are talking about one of my colorbar routines, they both use
the colors loaded in the current color table. These are set with the
NCOLORS
and BOTTOM keywords, which are used in exactly the same way as
the same keywords for LOADCT. Nothing is *ever* required with my
direct graphics routines to get high-quality PS output. :-)
> Thanks in advance for any guidance, or suggestions of other ways I can
> make an easy color bar. Earlier topics have been helpful to progress
> but I've been unable to fix these specifics.
In general, for direct graphics output, something like this works
reasonably well:
Window
LoadCT, 33, NColors=16, Bottom=1
Colorbar, NColors=16, Bottom=1, Divisions=1, XTickLen=1
Cheers,
David
|
|
|
Re: IDL Colorbar generation question [message #49330 is a reply to message #49146] |
Thu, 13 July 2006 01:07  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
britneys@ucla.edu writes:
> Thanks for all the help. I have one more question about the colorbar
> routine you've built. When I've used the call as above, I end up with
> a color bar where the first tenth or so of the bar is just vertical
> lines in a number of colors and the rest of the bar is as it should be.
> ANy idea why this would happen?
The Colorbar routine just loads the colors in the current
color table. If there are colored lines there, then I presume
this arise from colors that have been loaded into the color
table. (Perhaps drawing colors for something else, would be
my guess.) You might have to refresh the color table before
you call the Colorbar procedure with the colors you want
to see displayed.
If the problem is drawing colors, you can avoid loading them
in the color table by using decomposed color (Device, Decomposed=1)
and using FSC_COLOR to select drawing colors.
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
|
|
|
Re: IDL Colorbar generation question [message #49340 is a reply to message #49220] |
Wed, 12 July 2006 15:41  |
britneys
Messages: 3 Registered: July 2006
|
Junior Member |
|
|
Hi David,
Thanks for all the help. I have one more question about the colorbar
routine you've built. When I've used the call as above, I end up with
a color bar where the first tenth or so of the bar is just vertical
lines in a number of colors and the rest of the bar is as it should be.
ANy idea why this would happen?
THanks!
|
|
|