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

Karin Meier-Fleischer meier-fleischer at dkrz.de
Wed May 17 04:55:30 MDT 2017


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 
>> <mailto: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 <mailto: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/ee416fb4/attachment-0001.html 


More information about the ncl-talk mailing list