[ncl-talk] How to define XY Labels manually (gsn_csm_contour_map)

Mary Haley haley at ucar.edu
Wed May 17 09:34:48 MDT 2017


Hi Guido,

Could you email me the exact error message? I'm curious if there's
something we can improve on our end.

Karin's suggested method should work, as long as the tmXBValues that you
give it correspond with the actual values on your X axis.

There are some cases where the plotting function tries to label the axes
for you in a certain way (like if call gsn_csm_contour and you have
longitude values on the X axis), but most of them should allow you to
overwrite this with tmXBValues/tmXBLabels without complaining.

--Mary




On Wed, May 17, 2017 at 5:33 AM, Guido Cioni <guidocioni at gmail.com> wrote:

> That method didn't work for me sometimes as it was complaining because the
> variable that I was plotting had lat/lon attributes attached. But it should
> work most of the times.
> Cheers
>
> On 17 May 2017, at 12:55, Karin Meier-Fleischer <meier-fleischer at dkrz.de>
> wrote:
>
> Hi Cunbo and Guido,
>
> the simple way to do that is:
>
>   xvalues = (/ -10,     -5,     0,     5,     10/)
>   xlabels = (/"-10km", "-5km", "0km", "5km", "10km"/)
>
>   res at tmXBMode   = "Explicit"        ;-- set x-axis labeling to explicit
>   res at tmXBValues =  xvalues          ;-- values for x-axis tickmarks
>   res at tmXBLabels =  xlabels          ;-- set labels equal to values (type
> string)
>
> Bye,
> Karin
>
> Am 17.05.17 um 09:45 schrieb Guido Cioni:
>
> Hey Cunbo,
> that's a problem that I faced many times and I haven't found a clean
> solution, yet. All the methods that I've used to manually define the labels
> have failed somehow. The "easy" solution that I'm using now is to define a
> new variable for your axis and then use that for plotting.
>
> I believe you also have, like me, some coordinate informations in the x
> and y axis although the domain is idealized, that is defined only in terms
> of grid resolution, right? So what I've done was:
>
> ; 1 - defining the half-lenght of the two axis (in your case 10 km)
> half_lenght_x=10.
> half_lenght_y=10.
>
> ; 2 - manually compute the two axis as km
> ; using the longitude and latitude arrays from
> ; your input File
>
>  dist_x:=(half_lenght_x/180.)*(File->lon)
>  dist_x at units= "km"
>  dist_x at long_name = "Distance"
>  dist_x at standard_name = "distance"
>
>  dist_y:=(half_lenght_y/90.)*(File->lat)
>  dist_y at units= "km"
>  dist_y at long_name = "Distance"
>  dist_y at standard_name = "distance"
>
> ; 3 - use these two variables, which will have the same dimension as the
> coordinate variables, to plot
>  ResC at sfXArray := dist_x
>  ResC at sfYArray := dist_y
>
> Note that you will need to remove any reference to the old coordinate
> variables from the variable that you're plotting (so any attribute...).
>
> Hope that helps
>
> On 17 May 2017, at 09:28, Cunbo HAN <hancbo at gmail.com> wrote:
>
> Dear ncl-talk,
>
> I am doing a contour plot with “gsn_csm_contour_map” and I want to setup
> XY labels manually. Like in the attached plot, how can I change the
> XBLabels “10w, 5w, 0, 5E, 10E” to “-10km, -5km, 0km, 5km, 10km “? Does
> anyone know how to modify this? Thanks very much!
>
> Best,
> Cunbo
>
>
> <icon_shfx_50m_2d.png>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
>
> Guido Cioni
> http://guidocioni.altervista.org
>
>
>
> _______________________________________________
> ncl-talk mailing listncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
>
> Guido Cioni
> http://guidocioni.altervista.org
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170517/e0a5992b/attachment.html 


More information about the ncl-talk mailing list