Howdy,
I think I'm in over my head with IDL's color handling, and I would be
so grateful for any help!
I have a small plotting routine that uses PLOT to lay out a grid of
dots, and then POLYFILL to draw circles over selected grid dots, where
the color of the circle is drawn from a color table (and represents a
data value). I then add a COLORBAR, from D. Fanning's website, to add
a linear or log-scaled reference to the color values in the image.
I've had a lot of problems even getting this to display correctly on
my screen, and in particular, if I call this routine multiple times in
a row the colors always go very weird. I managed to get around this
by writing a reset_display routine that manually sets a bunch of
display variables, resetting my background to white etc.. But now,
after I have gotten these figures to display beautifully to screen, I
can't get them into any form of image file correctly.
My first attempt was:
write_png, 'myfile.png', tvrd(/true)
These png files have bizarre colors - violet or blue backgrounds and a
scheme not resembling the one on screen at all. I also tried just
writing to a ps file, but the ps device crashed on the used of the
DECOMPOSED keyword in colorbar. I have not tried messing with that
further yet.
I've experimented some with using TVREAD, and I have experimented
miscellaneously with setting the DECOMPOSED variable for the current
device, and playing with the options to TVRD, and I have tried a
SAVEIMAGE procedure by Liam Gumley, and various other little tricks on
the web, which claim to handle 24-bit true color images correctly.
Nothing changes. At this point I'm not even sure what to poke at to
make any progress. Any help?
I tossed together a quick example of the sort of thing I'm trying to
do. The typical calling sequence I would use for this is something
like:
IDL> plot_test,[0,2],color_scale=[1.1,23.]
IDL> write_png, 'testout.png',tvrd(/true)
The colors I get out don't resemble the ones that went in in the
least...
Thanks for any help,
Kathryn
----------------------------------------
pro plot_test, indices, color_scale = color_scale,$
log_color=log_color, title=title
; create grid of dots
; create a window for this display
if n_elements(title) eq 0 then title=''
; example simple grid of 4 points:
x_pos=[1., 2., 1., 2.]
y_pos=[1.,1.,2.,2]
;plot, the center points for each detector:
plot, x_pos, y_pos, xrange=[0,3],yrange=[0,3],/xstyle,/ystyle,/iso,$
psym = 3, title = title
; plotting:
Device, decomposed = 0
LoadCT, 33
if (keyword_set(color_scale)) then begin
original_color_scale=float(color_scale)
color_scale=float(color_scale)
if keyword_set(log_color) then begin
color_scale=alog10(color_scale)
endif
color_values = ((color_scale - min(color_scale))/max(color_scale))
* 255
endif
for i=0,n_elements(indices)-1 do begin
polyfill, circle(x_pos[indices[i]],y_pos[indices[i]],0.25), color=
color_values[i]
endfor
if keyword_set(log_color) then begin
colorbar, /vertical, /ylog, yticks=0,format='(F6.2)',$
range=[min(original_color_scale),max(original_color_scale)]
endif else begin
bar_title='Linear scale'
colorbar, /vertical, format='(F6.2)',$
range=[min(color_scale),max(color_scale)]
endelse
end
|