X
PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 23 Sep 2011 03:32 PM by  anon
EPS = black background?
 3 Replies
Sort:
You are not authorized to post a reply.
Author Messages

anon



New Member


Posts:
New Member


--
23 Sep 2011 03:32 PM
    So i wrote a program that plots certain data for climate models, and my supervisor is asking for EPS format. When i use IDL to plot it, the window comes up with all the data and map projections that i wanted, and everything looks good! But as soon as you SAVE it to .eps, theres a black background? if i save the EXACT same plot to .PNG there is no black background, which is exactly how i wanted it. Any ideas? heres my code. file1=ncdf_open('tnmin_hadex_1961_1990.nc') ncdf_varget,file1,'tnmin',tnmin ncdf_varget,file1,'lon',lon ncdf_varget,file1,'lat',lat ncdf_close,file1 lon=lon-180 lat=lat-2.8 d=size(tnmin) if d(0) EQ 1 then e=d(1)-1 if d(0) EQ 2 then e=d(4)-1 if d(0) EQ 3 then e=d(5)-1 setnewcb=0 f=500 for i2=0,e do begin if tnmin(i2) GT -101 $ then $ if f GT tnmin(i2) then f=tnmin(i2) endfor PRINT, 'Minimum Value:',f mapLimits = [Min(lat), Min(lon), Max(lat), Max(lon)] tnmin=reverse(tnmin,2) tnmin2=tnmin tnmin2(0:47,*)=tnmin(48:95,*) tnmin2(48:95,*)=tnmin(0:47,*) tnmin3=tnmin2 missing = Where(tnmin3 LT -999, count) IF count GT 0 THEN BEGIN tnmin3[missing] = !Values.F_NAN ENDIF minvalue = Floor(Min(tnmin3, /NAN)) maxvalue = Ceil(Max(tnmin3, /NAN)) scaledData = BytScl(tnmin3,top=20,/NaN,MIN=minvalue, max=maxvalue) nc=22.0 tn=FINDGEN(nc) maxmin=(maxvalue-minvalue)/nc tn(0)=minvalue for i=0.0,nc-2 do tn(i+1)=tn(i)+maxmin tns=string(tn, format='(F6.1)') countneg=0 for countnegs=0,nc-3 do begin if tn(countnegs) LT 0 then countneg=countneg+1 endfor DEVICE, DECOMPOSED = 0 loadct, 3, ncolors=nc ;TVLCT, RGB, /get If minvalue LT 0 then setnewcb =1 TVLCT, R1,G1,B1, /get loadct, 1, ncolors=nc TVLCT, RGB2, /get ;TVLCT, R2,G2,B2,/GET RGB1=indgen(256,3) RGB1(*,0)=reverse(R1) RGB1(*,1)=reverse(G1) RGB1(*,2)=reverse(B1) RGB1(0:20,0)=RGB1(235:255,0) RGB1(0:20,1)=RGB1(235:255,1) RGB1(0:20,2)=RGB1(235:255,2) ;RGB2=indgen(256,3) ;RGB2(*,0)=reverse(R2) ;RGB2(*,1)=reverse(G2) ;RGB2(*,2)=reverse(B2) ;RGB2(0:20,0)=RGB2(235:255,0) ;RGB2(0:20,1)=RGB2(235:255,1) ;RGB2(0:20,2)=RGB2(235:255,2) diff=20-countneg RGB3=indgen(256,3) if countneg GT 0 then begin RGB3(0:countneg-1,0)=RGB2(5:5+countneg-1,0) RGB3(countneg:20,0)=RGB1(235:235+diff,0) RGB3(0:countneg-1,1)=RGB2(5:5+countneg-1,1) RGB3(countneg:20,1)=RGB1(235:235+diff,1) RGB3(0:countneg-1,2)=RGB2(5:5+countneg-1,2) RGB3(countneg:20,2)=RGB1(235:235+diff,2) endif IF setnewcb EQ 0 then RGB3= RGB1 TVLCT, 255,255,255,23 misval=23 if countneg GT 0 then misval=255 IF count GT 0 THEN scaledData[missing] =misval m=map('robinson') im1 = Image(scaledData,lon,-lat,$ Limit=mapLimits, $ Grid_Units=2, $ Position=[0.05,0.15,0.5,1.0],$ RGB_Table=RGB3, title='tnmin_hadex_1961_1990.nc',/overplot) tn=FINDGEN(nc) maxmin=(maxvalue-minvalue)/nc tn(0)=minvalue for i=0.0,nc-2 do tn(i+1)=tn(i)+maxmin tns=string(tn, format='(F6.1)') table = Congrid(RGB3[0:20,*], 256, 3) ; table = Congrid(RGB2[11:20,*], 256, 3) fakeImage = Image(scaledData, lon, -lat, $ Grid_Units=2, $ Position=[0.05,0.15,0.95,0.90], RGB_Table=table, /overplot, /Hide) cb = Colorbar(Target=fakeImage,tickname=tns, /Border_On, $ Position=[0.1, 0.1, 0.9, 0.13],TickLen=0.5,minor=0) cb.font_size=5 map = im1.MapProjection grid = map.MapGrid map=mapcontinents() grid.label_position=0 grid.color = [75,75,75] grid.linestyle = 1 grid.grid_longitude = 90 grid.grid_latitude = 30 grid.font_size=10 ;filename='tnmin_hadex_1961_1990.eps' ;im1.save, filename ;im1.close end

    Deleted User



    New Member


    Posts:
    New Member


    --
    23 Sep 2011 05:24 PM
    Hi xAlbert, It seems to me that you are doing something similar to: pro plottest8 n_meas=100*366l*24 x=findgen(n_meas)/(n_meas*0.2) y=sin(x) p1 = plot(x,y) p1.color='blue' p1.save, 'plottesteps.eps' end That the above simple code produces a white background plot with a blue line plot in it?. Cheers, Fernando

    Deleted User



    New Member


    Posts:
    New Member


    --
    25 Sep 2011 08:27 PM
    A picture of what Albert is seeing can be found here: http://www.idlcoyote.com/ng_tips/blackpsbg.php As far as I can tell, every non-rectangular map projection produces a back background behind the map projection when the graphic is saved as a PostScript file. It would be wonderful to know how to get rid of it.

    Deleted User



    New Member


    Posts:
    New Member


    --
    26 Sep 2011 10:49 AM
    This turns out to be a bug in the way the transparency information is written to the PostScript device. It is logged as bug CR 62485 in the ITTVIS data base. Presumably it will be addressed in an upcoming IDL release.
    You are not authorized to post a reply.