Re: reversing the legend

From: Mary Haley (haley AT XXXXXX)
Date: Wed Feb 05 2003 - 17:24:26 MST

  • Next message: Jianping Pan: "Help on Build-in Function of "vinth2p_ecmwf""

    >
    > >
    > > Hi there -
    > >
    > > It seems that legends in an XY plot are in a reverse order from what I would call intuitive. That is, the 0th Y datum "vector" is the last legend item while the Nth Y datum is the first. For example, if I use:
    > >
    > > Y = some 2-D array with the first dimension 3
    > > res@xyExplicitLegendLabels = (/"0","1","2"/)
    > > res@xyDashPatterns = (/0,1,2/)
    > > plot = gsn_xy(wks,Xaxis,Y,res)
    > >
    > > then the datum Y(0,:) is plotted with a solid line and label "0", but it is the last item in the legend whereas I want it to be the first.
    > >
    > > This can of course be avoided by just reversing everything, but that's a pain in the neck. I feel I am missing something easy here, but does anyone know of an easy way to reverse the legend?
    > >
    > > Cheers,
    > > Josh
    >
    > Hi Josh,
    >
    > I'm afraid there's no easy way to reverse the legend, as you
    > discovered. I'll find out from the developers if this is an easy
    > feature to add.
    >
    > --Mary

    I should point out that you can create your own legend using the
    gsn_legend_ndc procedure. See:

       http://ngwww.ucar.edu/ngdoc/ng/ug/ncl/gsun/appendixa.html#gsn_legend_ndc

    for documentation, and:

      http://www.cgd.ucar.edu/csm/support/CSM_Graphics/legend.shtml

    for an example (example 6).

    Using gsn_legend_ndc may require that you set up quite a few
    resources, however, to get the dash patterns, colors, line labels,
    line label font heights and colors, etc, that you want. You could do
    this by retrieving all this information from your XY plot, or just
    creating them from scratch.

    See:

      http://ngwww.ucar.edu/ngdoc/ng/ref/hlu/obj/Legend.res.html

    to see a comprehensive list of all the available legend resources.

    --Mary
    _______________________________________________
    ncl-talk mailing list
    ncl-talk AT ucar.edu
    http://mailman.ucar.edu/mailman/listinfo/ncl-talk



    This archive was generated by hypermail 2b29 : Wed Feb 05 2003 - 17:26:34 MST