Re: Problem with overlaying gsn_csm_xy2 on a bar chart

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Tue Feb 09 2010 - 09:23:43 MST

Hi Shinx,

I thought I had an answer all ready for you, but the more I look at
this problem, I'm not so sure.

I think you are doing everything correctly, and the overlay should
have taken care of putting the various lines in the correct locations.

Can you email me offline and let me know if you can provide your
dataset so I can run the script here?

Thanks,

--Mary

On Feb 9, 2010, at 12:14 AM, Shinx wrote:

> Hi, All
>
>
>
> I have a problem when I overlay a gsn_csm_xy2 on a gsn_csm_xy,
> which res@gsnXYBarChart = True
>
> Here is my plot:
>
> http://shinx.myweb.hinet.net/TMIN.jpg
>
> The blue line with triangle marker is for y1(left side y-Axis) ,
> and the red line with dot marker is for y2(right side y-Axis)
>
> As the plot shows, y2 is not mapped properly to its X-Axis. It
> should be like y1 does.
>
> By the way, They were fine until I turned res(sky blue data)
> @gsnXYBarChart = True
>
>
>
> Any idea? Thanks,
>
>
>
> Shinx
>
>
>
>
>
> ;===============================================================
>
> ; test.ncl
>
> ;===============================================================
>
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
>
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
>
> ;
> ======================================================================
> ==
>
> begin
>
> ;=====================================================================
> ====
>
> ;=====================================================================
> ====
>
> inputfn="TMIN.txt"
>
> modelname="TMIN"
>
>
>
> ;=======================
>
> ; start to read in data
>
> ;=======================
>
> dummy = asciiread(inputfn,-1,"string")
>
> data = new((/8,12/),"float")
>
> data(0,:) = stringtofloat(str_get_field(dummy(1::), 1," "))
>
> data(1,:) = stringtofloat(str_get_field(dummy(1::), 2," "))
>
> data(2,:) = stringtofloat(str_get_field(dummy(1::), 3," "))
>
> data(3,:) = stringtofloat(str_get_field(dummy(1::), 4," "))
>
> data(4,:) = stringtofloat(str_get_field(dummy(1::), 5," "))
>
> data(5,:) = stringtofloat(str_get_field(dummy(1::), 6," "))
>
> data(6,:) = stringtofloat(str_get_field(dummy(1::), 7," "))
>
> data(7,:) = stringtofloat(str_get_field(dummy(1::), 8," "))
>
> dataset=new(8,"string")
>
> dataset(1)=str_get_field(dummy(0), 1," ")
>
> dataset(2)=str_get_field(dummy(0), 2," ")
>
> dataset(3)=str_get_field(dummy(0), 3," ")
>
> dataset(4)=str_get_field(dummy(0), 4," ")
>
> dataset(5)=str_get_field(dummy(0), 5," ")
>
> dataset(6)=str_get_field(dummy(0), 6," ")
>
> dataset(7)=str_get_field(dummy(0), 7," ")
>
>
>
> x=ispan(1,12,1)
>
>
>
> outputfn=modelname
>
> ;====================
>
> ; PLOT
>
> ;====================
>
> wks = gsn_open_wks("ps",outputfn)
>
>
>
> res0 = True ; lines with no marker
>
> resH = True ; Bar chart , Histogram
>
> resL = True ; y1
>
> resR = True ;y2
>
>
>
> resH@gsnDraw = False
>
> resH@gsnFrame = False
>
> resH@tmXBMode = "Explicit"
>
> resH@tmXBValues = data(0,:)
>
> resH@tmXBLabels = data(0,:)
>
> resH@gsnMaximize = True
>
> resH@gsnPaperOrientation = "portrait"
>
>
>
> resR = resH
>
>
>
> resH@trYMinF = 0
>
> resH@trYMaxF = 3.5
>
>
>
> res0 = resH
>
> resL = resH
>
>
>
> resH@tmXTOn = False
>
> resH@tmYROn = False
>
> resH@gsnXYBarChart = True ; turn on bar
> chart
>
> resH@gsnXYBarChartBarWidth = 0.75 ; change bar
> widths
>
> resH@gsnXYBarChartColors = "SkyBlue"
>
>
>
> res0@xyDashPattern = 0
>
> res0@xyMarkLineMode = "Lines" ; Markers *and* lines
>
> res0@xyLineColors = "black"
>
> res0@tmXTOn = False
>
> res0@tmYROn = False
>
>
>
>
>
> resR@xyDashPattern = 0
>
> resR@trYMinF = 0
>
> resR@trYMaxF = 1
>
> resR@tiYAxisString = "COR"
>
> resR@tiYAxisFontHeightF = 0.01
>
> resR@xyMarkLineMode = "MarkLines" ; Markers
> *and* lines
>
> resR@xyMarkers = 16
>
> resR@xyLineColors = "red"
>
> resR@xyMarkerColors = "red"
>
> resR@xyMarkerSizeF = 0.01
>
>
>
> resL@xyDashPattern = 0
>
> resL@tiYAxisString = "RMS"
>
> resL@tiYAxisFontHeightF = 0.01
>
> resL@xyMarkLineMode = "MarkLines" ; Markers
> *and* lines
>
> resL@xyMarkers = 7
>
> resL@xyLineColors = "blue"
>
> resL@xyMarkerColors = "blue"
>
> resL@xyMarkerSizeF = 0.01
>
>
>
>
>
> plotH=gsn_csm_xy(wks,data(0,:),data(1,:),resH)
>
> plot0=gsn_csm_xy(wks,data(0,:),data(3:6,:),res0)
>
> plotL=gsn_csm_xy2(wks,data(0,:),data(2,:),data(7,:),resL,resR)
>
>
>
> overlay(plotH,plot0)
>
> overlay(plotH,plotL)
>
>
>
> draw(plotH)
>
> frame(wks)
>
>
>
>
>
> system("convert -density 300 -trim "+outputfn+".ps "+outputfn
> +".png")
>
> system("rm "+outputfn+".ps") ;delete .ps file
>
>
>
> end
>
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Tue Feb 9 09:23:58 2010

This archive was generated by hypermail 2.1.8 : Thu Feb 11 2010 - 09:50:35 MST