[ncl-talk] text res
Mary Haley
haley at ucar.edu
Fri Oct 16 10:23:21 MDT 2015
Geeta,
Your "if" statement is wrong. The condition "if any(rf.le.4.1)" is always
going to resolve as True, because you are checking if *any* one of the rf
values is <= 4.1. The "else" part of the statement never gets executed.
If you want to set a different font color for each value, then you will
need a do loop, because unfortunately we don't have a "txFontColors" type
of resource that allows you to set an array of colors.
Here's what your loop would look like:
nrf = dimsizes(rf)
colors = where(rf.le.4.1,"Blue","Red")
text = new(nrf,graphic)
do n=0,nrf-1
txres at txFontColor = colors(n)
text(n) =
gsn_add_text(wks,plot,sprintf("%9.4g",rf(n)),lon(n),lat(n),txres)
end do
draw(plot)
frame(wks)
On Thu, Oct 15, 2015 at 11:49 AM, Geeta Geeta <geetag54 at yahoo.com> wrote:
> Yes I meant "clumsy " as the values close to the dots.
> Yes all your suggestions are working very well.
> Thanks a lot for that.
>
> I have another question. I was wondering if I can give different colours
> to the values. I mean if rainfall in in range of 0.1-2.4, then I write the
> actual value by Yellow color
> if 2.5 -10.0 say then I write the actual value by Green color
>
> Instead of all uniform colour like Blue I have chosen
>
> For this I tried with if statement before the Text Res like this.
>
> txres = True
> txres at txFontHeightF = 0.012
> txres at txFont = "helvetica-bold"
> ;
> if any(rf.le.4.1) then
> txres at txFontColor = "Blue"
> ; txres at txFontQuality = "High"
> ; txres at txJut = "TopRight "
> else
> if any(rf.gt.4.1) then
> txres at txFontColor = "Red"
> end if
> end if
>
> text = gsn_add_text(wks,plot," "+sprintf("%9.4g",rf),lon,lat,txres)
>
> But It is plotted in Blue only.
> my input file looks like this.
> lat lon hgt rf
> 12.57 77.38 919.6 5.6
> 12.3 78.18 882.2 67.
> 13.06 77.24 900 0.1
> 13.26 77.24 900 4.1
>
> If I dont use any function then I get error.
>
> Geeta.
>
>
>
> On Wednesday, 14 October 2015 12:34 AM, Mary Haley <haley at ucar.edu> wrote:
>
>
> Geeta,
>
> I'm not sure what you mean by "messy".
>
> You are setting txPosXF and txPosYF, but these resources are meaningless,
> because the "gsn_add_text" function has the X and Y positions as part of
> its argument list, in your case, the "lon" and "lat" arguments:
> text = gsn_add_text(wks,plot,sprintf("%9.4g",rf),lon,lat,txres)
> So, you should be trying to change your lon and lat values, and not
> txPosXF and txPosYF.
> If by "messy" you mean that the text string is touching the markers in a
> couple of places, then there are several things you can do.
> One is to simply add some extra spaces before the text strings. You can do
> this by changing the format in the "sprintf" call to have more fields:
> text = gsn_add_text(wks,plot,sprintf("%11.4g",rf),lon,lat,txres)
> or by adding a space:
> text = gsn_add_text(wks,plot," " + sprintf("%9.4g",rf),lon,lat,txres)
> You can also add a small delta value to the "lon" position:
> text = gsn_add_text(wks,plot,sprintf("%9.4g",rf),lon+0.1,lat,txres)
> --Mary
>
>
>
>
>
> On Mon, Oct 12, 2015 at 11:14 AM, Geeta Geeta <geetag54 at yahoo.com> wrote:
>
> Hi.
> I am plotting station rainfall and my data looks like
> 13.57 77.38 919.6 5.6
> 12.3 78.18 882.2 67.
> 13.06 77.24 900 0.1
> 13.06 77.24 900 0.1
> ~
> The Rf is in the 4th Col and it gets plotted. But when I try to change the
> position of the text, I am unable to do it.
> My script is attached and the Figure.
>
> essentially,
>
> txres at txPosXF = 0.775
> txres at txPosYF = -5.05
> ; txres at txAngleF = 40.00
>
> Since I am unable to change the above two, my plot looks a little messy.
>
> can someone suggest???
>
> Geeta.
>
> _______________________________________________
> 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/20151016/87fea20d/attachment.html
More information about the ncl-talk
mailing list