Hi Nilesh,
There are a couple of ways you can do this. Unfortunately, one of the
ways won't be available until the next release of ncl, which is via
the "gsn_add_annotation" routine.
However, you can do this another way by creating the plot but not
drawing it, retrieving the axes limits, and then placing the
string based on these limits. The code snippet below shows how to
do this for a string in the upper right corner of the plot.
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
begin
x = (/10.,20.,30.,40.,50.,60.,70.,80.,90./)
y = (/0.,0.71,1.,0.7,0.002,-0.71,-1.,-0.71,-0.003/)
wks = gsn_open_wks("x11","annotate")
res = True
res_at_gsnDraw = False ; Don't draw the plot or
res_at_gsnFrame = False ; advance the frame just yet.
plot = gsn_csm_xy(wks,x,y,res)
getvalues plot
"trXMaxF" : xmax ; Retrieve the max X axis and
"trYMaxF" : ymax ; max Y axis limits.
end getvalues
txres = True ; Set some text resources.
txres_at_txFontHeightF = 0.02
txres_at_txJust = "TopRight" ; Position the string by its
; upper right corner.
dum = gsn_add_text(wks,plot,"Top Right String",xmax,ymax,txres)
draw(plot) ; Now draw the plot and
frame(wks) ; advance the frame.
end
This is just one way of doing this. If you know what your axis limits
are going to be apriori, then you don't need to do the whole "getvalues"
step to retrieve them.
--Mary
On Thu, 24 Aug 2006 araligin_at_onid.orst.edu wrote:
>
> Hi ,
>
> I am having trouble putting a text in a xy plot. My X and Y axis keeps on
> changing and I want the text to be always on the top right corner of the plot.
> Is there any way to check for the maximum value of the X and Y axis and position
> the text according to that.
>
> Thanking you,
> Nilesh
> _______________________________________________
> ncl-talk mailing list
> ncl-talk_at_ucar.edu
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Aug 25 2006 - 09:11:31 MDT
This archive was generated by hypermail 2.2.0 : Fri Aug 25 2006 - 11:50:14 MDT