Re: using map_set with postscript device [message #63821] |
Thu, 20 November 2008 21:57  |
TonyL
Messages: 14 Registered: November 2008
|
Junior Member |
|
|
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
|
|
|
Re: using map_set with postscript device [message #63822 is a reply to message #63821] |
Thu, 20 November 2008 21:22   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
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.")
|
|
|
Re: using map_set with postscript device [message #63942 is a reply to message #63822] |
Sun, 23 November 2008 14:27  |
pepperjack
Messages: 2 Registered: November 2008
|
Junior Member |
|
|
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.")
Thanks very much for your help - I have something that works looking
like this:
set_plot, 'ps'
device, /encapsulated, filename = filename
device, /color, bits_per_pixel=8
!p.region = [0.0, 0.0, 1, 1]
loadct, 33 ;select colour
table
range = max(chi_hlm1_sm)-min(chi_hlm1_sm) ;set range to
plot
step = range/20.
clevs = (indgen(21)*step) + min(chi_hlm1_sm)
ccols = indgen(20)*(254/19)
contour, chi_hlm1_sh, data.lon-180., y, levels=clevs,/cell_fill,
xstyle=1, ystyle=1\
,yrange=[-90,90], xrange=[-180,177.5], pos=[0.05 ,0.18 ,0.95 ,0.818]
map_set,/noerase,/continents,/grid,/isotropic, pos=[0.05 , 0.05,
0.95, 0.95]
colorbar, 1e+3*clevs,ccols,format = '(i4)'
device,/close
I have a couple of questions though, if you don't mind...
Is there an easier way to work out what vectors should go in the
POSITION keyword? These numbers appear to be totally random to me, and
I found them through trial and error...
Is there a way to manage the file size of the resulting .eps? I need
to compile about 100 of these figures into a latex document and it is
rapidly growing to an unmanageable size.
Thanks for your help
R
|
|
|