On Nov 21, 4:22 pm, David Fanning <n...@dfanning.com> wrote:
> pepperjack writes:
>> I'm trying to overplot a contour with a map using contour .... /
>> overplot followed by map_set ... /noerase. It works fine when I output
>> it to my screen, but when I output it to a .eps file the map_set turns
>> the entire plot one colour so I lose my contours.
>
>> Here is my code:
>
>> set_plot, 'ps'
>> device, /encapsulated, filename='chi.eps'
>> device, /color
>> !p.region = [0.0, 0.1, 1, 1]
>> loadct, 33
>> range = max(chi) - min(chi)
>> step = range/20.
>> clevs = (indgen(21)*step) + min(chi)
>> ccols = indgen(20)*(254/19)
>> contour, chi, x, y, levels=clevs,c_col=ccols,/cell_fill,/overplot
>> map_set,/noerase,/continents,/grid,/isotropic
>> colorbar, clevs,ccols, format='(i4)'
>> device,/close
>
>> I'd really appreciate any help anyone can offer with this.
>
> Well, I'm having a REALLY hard time seeing how this code
> "works fine" when output to the display. :-)
>
> Here are a couple of things I see immediately:
>
> 1. Remove the OVERPLOT keyword to Contour. Otherwise, you will
> draw over the top of what is already in the display or file.
>
> 2. You need a BITS_PER_PIXEL=8 keyword on your DEVICE command.
>
> 3. There is no way your contour plot and your map are going
> to align, unless you specify a POSITION for them.
>
> 4. If that Colorbar routine came from my web page, it isn't
> going to work at all if called like that.
>
> Cheers,
>
> David
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming:http://www.dfanning.com/
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")
Hi Peppercorn,
If you download DAvid's Coyote library and install Imagemagick from
its own website, you can generate good Postscript output easily as per
this attached code.
pro test_group1
;choose windows screen display or PS output
ps_flag = 1
Case ps_flag of
0: begin
window,/free, xsize=600,ysize=600, pixmap=0
device,dec = 0
end
1: begin
window,/free, xsize=600,ysize=600, pixmap=1
filename = 'D:\temp\test.ps'
PS_Start, FILENAME=filename
end
Else:
Endcase
; make up some data
chi = DIST(40,40)
;define color fill values
data_range = [min(chi),max(chi)]
dmin = data_range[0] & dmax = data_range[1]
n_levels = 256
fill_levels = findgen(n_levels)/(n_levels-1)*(dmax-dmin)+dmin
; define some lat/lon values assoc with chi
lats = [-40+0.5*findgen(40)]
lons = [130+0.5*findgen(40)]
limit = [min(lats),min(lons),max(lats),max(lons)]
polon = limit[1] + 0.5*(limit[3]-limit[1])
polat = 0
map_set,polat,polon, 0, limit=limit, /isotropic
loadct,33
contour, chi, lons, lats, /noerase, levels=fill_levels, $
c_colors=fill_colors, /data, /overplot, xstyle=1, ystyle=1, /fill
map_continents,/hires
; save to PNG
Case ps_flag of
0:
1: PS_End, /PNG
Else:
Endcase
end
|