[ncl-talk] 12-panel plot is 28Mb

Mary Barth barthm at ucar.edu
Thu Oct 29 09:21:07 MDT 2015


Hi there,

I have created a 12-panel plot, which looks great for my paper, but is 
28 Mb in size as a *ps file. Is there anything I can do in my ncl script 
to make it smaller? The script is attached.

BTW, running ps2pdf afterwards converted the ps file to a 5.4 Mb pdf file.

Thanks!
Mary

-------------- next part --------------
;*********************************************************************
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"
;*********************************************************************
begin 

 prefix = "CloudFree_"
 suffix = ".txt"

 year  = 2012
 cyear = "2012"

 months = (/  5,  5, 6, 6,  6,  6 /)
 days   = (/ 18, 29, 2, 6, 16, 22 /)
 dmon = dimsizes(months)
 nmon = dmon(0)
 
 panel_labels = (/ "a) 18 May 2012", "b) 29 May 2012", "c) 2 June 2012",   \
                   "d) 6 June 2012", "e) 16 June 2012", "f) 22 June 2012" /)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Set up plotting configuration
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 wks = gsn_open_wks("ps",prefix+"_plot")

  res = True
  res at vpWidthF  = 0.18           ; 0.25
  res at vpHeightF = 0.27           ; 0.40

; Locate the top-left corner of each case's plots
  xtl    = (/ 0.1, 0.55, 0.1, 0.55, 0.1, 0.55 /)
  ytl    = (/ 0.97,0.97, 0.67,0.67, 0.37,0.37 /)


  fontht = 0.015
  res at tmXBLabelFont        = 21
  res at tmXBLabelFontHeightF = 0.015
  res at tmXBMode             = "Manual"

  res at tmYLLabelFont        = res at tmXBLabelFont
  res at tmYLLabelFontHeightF = res at tmXBLabelFontHeightF
  res at tmYLMode             = "Manual"

  res at tiMainFontHeightF = fontht + 0.003
  res at tiMainFont        = 21

  res at tiXAxisFontHeightF = fontht ;     + 0.003
  res at tiXAxisFont        = 21

  res at tiYAxisFontHeightF = res at tiXAxisFontHeightF
  res at tiYAxisFont        = res at tiXAxisFont

  res at gsnFrame = False

  res at tmXBMinorPerMajor = 4
  res at tmXBTickStartF    = 0.
  res at tmYLMinorPerMajor = 4
  res at tmYLTickStartF    = 0.

  res at trYMinF = 0.
  res at trYMaxF = 13.

  res at tiMainString  = " "

  res at xyMarkLineModes  = "MarkLines"
  res at xyMarkers = 16
  res at xyLineThicknessF = 2
  res at xyDashPattern    = 0

 txres = True
 txres at txFontHeightF = fontht
 txres at txFont        = 21
 txres at txJust        = "CenterLeft"
 txres at txPerimOn     = False


 res at vpXF = 0.10
 res at vpYF = 0.90




 do imon=0,nmon-1
    
  month = months(imon)
  day   = days(imon) 
  cmon = "18"
  if(month.lt.10) then
    cmon = "0"+month
  else
    cmon = month
  end if
  cday = "05"
  if(day.lt.10) then
    cday = "0"+day
  else
    cday = day
  end if

  filein = prefix+cmon+cday+suffix
  print(" reading from  "+filein)

  ncols = 13
  head = readAsciiHead(filein, 1)
  cfdata = readAsciiTable(filein, ncols, "float", 1)
  nalt = dimsizes(cfdata(:,0))
  print(" " + filein + "  has " + nalt + " rows and " + ncols + " columns of data.")

  yvar = cfdata(:,0)              ; altitude (km)

 res at vpXF = xtl(imon)
 res at vpYF = ytl(imon)
 if(xtl(imon) .eq. 0.1) then
  res at tiYAxisString = "Altitude (km)"
  res at tmYLLabelsOn = True
 else
  res at tiYAxisString = ""
  res at tmYLLabelsOn = False
 end if
 if(ytl(imon) .lt. 0.4) then
  res at tiXAxisString = "Mixing Ratio (pptv)"
  res at tmXBLabelsOn = True
 else
  res at tiXAxisString = ""
  res at tmXBLabelsOn = False
 end if
 res at trXMinF = 0.
 res at trXMaxF = 1500.
 res at tmXBTickEndF      = 1500.
 res at tmXBTickSpacingF  =  500
 res at xyMarkerColor    = "blue"
 res at xyLineColor      = "blue"

 xvar = cfdata(:,1)
 plot1 = gsn_csm_xy (wks, xvar, yvar, res)
 x1 = xvar - cfdata(:,7)
 x1 = where(x1 .le. 0., 0.01, x1)
 x2 = xvar + cfdata(:,7)
 do ik=0,nalt-1
   plot1 = gsn_csm_xy (wks, (/x1(ik), x2(ik)/), (/yvar(ik), yvar(ik)/), res)
   plot1 = gsn_csm_xy (wks, (/x1(ik), x1(ik)/), (/yvar(ik)+0.1, yvar(ik)-0.1/), res)
   plot1 = gsn_csm_xy (wks, (/x2(ik), x2(ik)/), (/yvar(ik)+0.1, yvar(ik)-0.1/), res)
 end do
 delete(x1)
 delete(x2)

iskip=1
if(iskip .gt. 0) then
 res at xyMarkerColor    = "red"
 res at xyLineColor      = "red"
 xvar = cfdata(:,2)
 plot1 = gsn_csm_xy (wks, xvar, yvar, res)
 x1 = xvar - cfdata(:,8)
 x1 = where(x1 .le. 0., 0.01, x1)
 x2 = xvar + cfdata(:,8)
 do ik=0,nalt-1
   plot1 = gsn_csm_xy (wks, (/x1(ik), x2(ik)/), (/yvar(ik), yvar(ik)/), res)
   plot1 = gsn_csm_xy (wks, (/x1(ik), x1(ik)/), (/yvar(ik)+0.1, yvar(ik)-0.1/), res)
   plot1 = gsn_csm_xy (wks, (/x2(ik), x2(ik)/), (/yvar(ik)+0.1, yvar(ik)-0.1/), res)
 end do
 delete(x1)
 delete(x2)

 res at xyMarkerColor    = "black"
 res at xyLineColor      = "black"
 xvar = cfdata(:,3)
 plot1 = gsn_csm_xy (wks, xvar, yvar, res)
 x1 = xvar - cfdata(:,9)
 x1 = where(x1 .le. 0., 0.01, x1)
 x2 = xvar + cfdata(:,9)
 do ik=0,nalt-1
   plot1 = gsn_csm_xy (wks, (/x1(ik), x2(ik)/), (/yvar(ik), yvar(ik)/), res)
   plot1 = gsn_csm_xy (wks, (/x1(ik), x1(ik)/), (/yvar(ik)+0.1, yvar(ik)-0.1/), res)
   plot1 = gsn_csm_xy (wks, (/x2(ik), x2(ik)/), (/yvar(ik)+0.1, yvar(ik)-0.1/), res)
 end do
 delete(x1)
 delete(x2)

 res at xyMarkerColor    = "forestgreen"
 res at xyLineColor      = "forestgreen"
 res at xyDashPattern = 16
 xvar = cfdata(:,4)
 plot1 = gsn_csm_xy (wks, xvar, yvar, res)
 res at xyDashPattern = 0
 x1 = xvar - cfdata(:,10)
 x1 = where(x1 .le. 0., 0.01, x1)
 x2 = xvar + cfdata(:,10)
 do ik=0,nalt-1
   plot1 = gsn_csm_xy (wks, (/x1(ik), x2(ik)/), (/yvar(ik), yvar(ik)/), res)
   plot1 = gsn_csm_xy (wks, (/x1(ik), x1(ik)/), (/yvar(ik)+0.1, yvar(ik)-0.1/), res)
   plot1 = gsn_csm_xy (wks, (/x2(ik), x2(ik)/), (/yvar(ik)+0.1, yvar(ik)-0.1/), res)
 end do
 delete(x1)
 delete(x2)
end if         ; iskip

 draw(plot1)
 
 xpt = res at vpXF + 0.08
 ypt = res at vpYF - 0.07 - 0.00
 txres at txFontColor = "blue"
 gsn_text_ndc(wks, "n-butane", xpt, ypt, txres)

 ypt = res at vpYF - 0.07 - 0.03
 txres at txFontColor = "red"
 gsn_text_ndc(wks, "i-butane", xpt, ypt, txres)

 ypt = res at vpYF - 0.07 - 0.06
 txres at txFontColor = "black"
 gsn_text_ndc(wks, "n-pentane", xpt, ypt, txres)

 ypt = res at vpYF - 0.07 - 0.09
 txres at txFontColor = "forestgreen"
 gsn_text_ndc(wks, "i-pentane", xpt, ypt, txres)


 res at tmXBTickStartF    = 0.
 res at tmXBMode             = "Manual"

 res at vpXF = res at vpXF + 0.22
 res at tiYAxisString = ""
 if(ytl(imon) .lt. 0.4) then
  res at tiXAxisString = "Mixing Ratio (ppbv)"
 end if
 res at tmYLLabelsOn = False
 res at trXMinF = 0.
 res at trXMaxF = 4.
 res at tmXBTickEndF      = 4.
 res at tmXBTickSpacingF  = 1
 res at xyMarkerColor    = "blue"
 res at xyLineColor      = "blue"
 xvar = cfdata(:,5) * 0.001
 plot3 = gsn_csm_xy (wks, xvar, yvar, res)
 x1 = xvar - cfdata(:,11) * 0.001
 x2 = xvar + cfdata(:,11) * 0.001
 do ik=0,nalt-1
   plot3 = gsn_csm_xy (wks, (/x1(ik), x2(ik)/), (/yvar(ik), yvar(ik)/), res)
   plot3 = gsn_csm_xy (wks, (/x1(ik), x1(ik)/), (/yvar(ik)+0.1, yvar(ik)-0.1/), res)
   plot3 = gsn_csm_xy (wks, (/x2(ik), x2(ik)/), (/yvar(ik)+0.1, yvar(ik)-0.1/), res)
 end do
 delete(x1)
 delete(x2)
 res at xyMarkerColor    = "red"
 res at xyLineColor      = "red"
 xvar = cfdata(:,6) * 0.001
 plot3 = gsn_csm_xy (wks, xvar, yvar, res)
 x1 = xvar - cfdata(:,12) * 0.001
 x2 = xvar + cfdata(:,12) * 0.001
 do ik=0,nalt-1
   plot3 = gsn_csm_xy (wks, (/x1(ik), x2(ik)/), (/yvar(ik), yvar(ik)/), res)
   plot3 = gsn_csm_xy (wks, (/x1(ik), x1(ik)/), (/yvar(ik)+0.1, yvar(ik)-0.1/), res)
   plot3 = gsn_csm_xy (wks, (/x2(ik), x2(ik)/), (/yvar(ik)+0.1, yvar(ik)-0.1/), res)
 end do
 delete(x1)
 delete(x2)
 draw(plot3)

 txres at txFontHeightF = fontht + 0.001
 xpt = res at vpXF + 0.01 - 0.22           ; 0.22 to move it back to first plot
 ypt = res at vpYF - 0.02
 txres at txFontColor = "black"
 gsn_text_ndc(wks, panel_labels(imon), xpt, ypt, txres)

 txres at txFontHeightF = fontht
 xpt = res at vpXF + 0.09
 ypt = res at vpYF - 0.05 - 0.02
 txres at txFontColor = "blue"
 gsn_text_ndc(wks, "H~B~2~N~O~B~2~N~", xpt, ypt, txres)

 ypt = res at vpYF - 0.05 - 0.05
 txres at txFontColor = "red"
 gsn_text_ndc(wks, "CH~B~3~N~OOH", xpt, ypt, txres)

 delete(cfdata)
 delete(yvar)
 delete(xvar)

 end do              ; imon

 frame(wks)

end


More information about the ncl-talk mailing list