Re: Problem with bar plots

From: Adam Phillips (asphilli AT cgd.ucar.edu)
Date: Wed Jun 29 2005 - 12:39:38 MDT

  • Next message: Fred Clare: "Re: natgrid"

    Hi Andrea,

    I think you want to use gsnXYBarChartColors2 instead of
    gsnXYBarChartColors.. gsnXYBarChartColors is used to set the colors of
    individual bars when there isn't a reference line set,
    gsnXYBarChartColors2 is used to set the colors of individual bars when
    there is a reference line set. See:
    http://www.ncl.ucar.edu/Document/Graphics/Resources/gsn.shtml#gsnXYBarChartColors

    The 0 bar is failing because it is considered to be on the other side of
    the reference line, and gsnXYBarChartColors can't handle that. Running
    your script using gsnXYBarChartColors2 produces the correct results.

    Hope that helps.
    Adam

    Andrea Hahmann wrote:
    > Hi!
    >
    > I have a bit of a problem with a "bar plot". I am trying to compare
    > model biases between two sets of model simulations, with two different
    > colors, in bar plot. What I have done is to combine the biases together
    > (model1, model2, model1, model2, and so on) to form a single vector and
    > then plot it using "gsn_csm_xy" with "gsnXYBarChart=True".
    >
    > On the first example (top panel) the boxes are purple, green, purple,
    > etc. as they should be. In the second case, since one of the values is
    > 0. the order of the colors is messed up.
    >
    > Attached are the ncl script and gif image.
    >
    > Any help will be appreciated!
    > Andrea
    >
    > ----------------------------------------------------------------
    > Andrea N. Hahmann, Ph.D.
    > Research Applications Laboratory
    > Natl. Center for Atmospheric Research Phone: 1-303-497-8383
    > PO BOX 3000 Fax: 1-303-497-8401
    > Boulder, CO 80301 hahmann@ucar.edu
    > ----------------------------------------------------------------
    >
    > ------------------------------------------------------------------------
    >
    >
    > ------------------------------------------------------------------------
    >
    > load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
    > load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
    >
    > begin
    >
    > res = True ; plot mods desired
    > res@gsnDraw = False ; don't draw
    > res@gsnFrame = False ; don't advance frame
    >
    > res@gsnXYBarChart = True ; turn on bar chart
    > res@gsnYRefLine = 0. ; reference line
    > res@gsnXYBarChartBarWidth = 0.8
    > res@gsnXYBarChartColors = (/"purple","green","purple","green","purple", \
    > "green","purple","green"/)
    >
    > x = (/-0.4,0.4, 1.6,2.4, 3.6,4.4, 5.6,6.4/)
    > bias = (/-0.15,-0.05,-0.44,-0.47,-0.55,-0.55,-0.63,-0.57 /)
    >
    > wks = gsn_open_wks("ps","bar") ; open ps file
    > plot = new(2,graphic) ; create a plot array
    >
    > plot(0) = gsn_xy (wks,x,bias,res)
    >
    > bias = (/-0.15,0.00,-0.44,-0.47,-0.55,-0.55,-0.63,-0.57 /)
    > plot(1) = gsn_xy (wks,x,bias,res)
    >
    > resP = True
    > gsn_panel(wks,plot,(/2,1/),resP) ; now draw as one plot
    >
    >
    > end
    >
    >
    > ------------------------------------------------------------------------
    >
    > _______________________________________________
    > ncl-talk mailing list
    > ncl-talk@ucar.edu
    > http://mailman.ucar.edu/mailman/listinfo/ncl-talk

    -- 
    --------------------------------------------------------------
    Adam Phillips			             asphilli@ucar.edu
    National Center for Atmospheric Research   tel: (303) 497-1726
    ESSL/CGD                                   fax: (303) 497-1333
    P.O. Box 3000				
    Boulder, CO 80307-3000	  http://www.cgd.ucar.edu/cas/asphilli
    _______________________________________________
    ncl-talk mailing list
    ncl-talk@ucar.edu
    http://mailman.ucar.edu/mailman/listinfo/ncl-talk
    



    This archive was generated by hypermail 2b29 : Wed Jun 29 2005 - 12:52:12 MDT