Re: how to plot a scalar on a x-y bar graph

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Fri Oct 01 2010 - 09:52:01 MDT

Sorry, Mark, I inadvertently added the "-" in front of your value for y3! Ignore my previous message about changing trYMaxF and setting gsnYRefLine. The work-around should still apply.

--Mary

On Oct 1, 2010, at 9:37 AM, Mary Haley wrote:

> Hi Mark,
>
> I think I can fix the code so that one bar is allowed.
>
> You can work around this for now by creating an array with three elements, but two of them are missing:
>
> lst3 = (/2,3,4/)
> y3 = (/-999,-1,-999/)
> y3@_FillValue = -999
>
> There is a different problem, however. The trYMinF resource is set to 0, but this third bar is set to y = -1. This will cause this bar to not show up in the overlay.
> If you are expecting the "negative" bar to point downward, then you can set trYMaxF to -2, and add sres@gsnYRefLine = 0.:
>
> begin
> wks = gsn_open_wks("x11","bar")
>
> sres = True
> sres@gsnDraw = False
> sres@gsnFrame = False
> sres@gsnXYBarChart = True
> sres@trYMinF = -2
> sres@trYMaxF = 10.
> sres@gsnXYBarChartBarWidth = 0.25
> sres@gsnYRefLine = 0.0
>
> lst1 = (/1.,4.,7./)
> y1 = (/6.,7.,8./)
>
> lst2 = (/2.,5.,8./)
> y2 = (/2.,3.,5./)
>
> lst3 = (/2,3,4/)
> y3 = (/-999,-1,-999/)
> y3@_FillValue = -999
>
> printVarSummary(lst3)
>
> sres@gsnXYBarChartColors = "green"
> plot = gsn_csm_xy(wks,lst1,y1,sres)
> sres@gsnXYBarChartColors = "brown"
>
> plot_1 = gsn_csm_xy(wks,lst2,y2,sres)
> sres@gsnXYBarChartColors = "red"
> plot_2 = gsn_csm_xy(wks,lst3,y3,sres)
> overlay(plot,plot_1)
> overlay(plot,plot_2)
> draw(plot)
> frame(wks)
> end
>
>
> On Sep 30, 2010, at 7:18 PM, mark collier wrote:
>
>> Hi,
>> my script
>>
>> begin
>> wks = gsn_open_wks("x11","bar")
>>
>> sres = True
>> sres@gsnDraw = False
>> sres@gsnFrame = False
>> sres@gsnXYBarChart = True
>> sres@trYMinF = 0.
>> sres@trYMaxF = 10.
>> sres@gsnXYBarChartBarWidth = 0.25
>>
>> lst1 = (/1.,4.,7./)
>> y1 = (/6.,7.,8./)
>>
>> lst2 = (/2.,5.,8./)
>> y2 = (/2.,3.,5./)
>>
>> lst3 = (/3.,6.,9./)
>> y3 = (/1.,1.,1./)
>>
>> ;lst3 = (/3/)
>> ;y3 = (/1/)
>>
>> printVarSummary(lst3)
>>
>> sres@gsnXYBarChartColors = "green"
>> plot = gsn_csm_xy(wks,lst1,y1,sres)
>> sres@gsnXYBarChartColors = "brown"
>> plot_1 = gsn_csm_xy(wks,lst2,y2,sres)
>> sres@gsnXYBarChartColors = "red"
>> plot_2 = gsn_csm_xy(wks,lst3,y3,sres)
>> overlay(plot,plot_1)
>> overlay(plot,plot_2)
>> draw(plot)
>> frame(wks)
>> end
>>
>> works, however, if I change my third set of values to a scalar (lst3/
>> y3), I get the error:
>>
>> fatal:Subscript out of range, error in subscript #0
>> fatal:An error occurred reading x
>> fatal:Execute: Error occurred at or near line 161 in file $NCARG_ROOT/
>> lib/ncarg/nclscripts/csm/gsn_csm.ncl
>>
>> fatal:Execute: Error occurred at or near line 4337 in file $NCARG_ROOT/
>> lib/ncarg/nclscripts/csm/gsn_csm.ncl
>>
>> fatal:Execute: Error occurred at or near line 31 in file
>> test_xy_plot.ncl
>>
>> clearly it doesn't like the fact that I just have one x/y pair. In my
>> script I just set a dummy value to it (turn it into a vector) and it
>> works. However, this isn't very elegant. Is there a way of forcing the
>> single value to be plotted?
>>
>> Many thanks,
>> Mark.
>>
>>
>> _______________________________________________
>> 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

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Oct 1 09:52:06 2010

This archive was generated by hypermail 2.1.8 : Mon Oct 04 2010 - 08:55:54 MDT