[ncl-talk] two y axises
Mary Haley
haley at ucar.edu
Tue Oct 2 09:14:56 MDT 2018
Ehsan,
There are a few issues with your script:
1. When plotting against time that is in YYYYMM/YYYYMMDD/YYYYMMDDHH type of
format, it is best to use one of our "yyyymmxxx_to_yyfrac" routines to
create a fractional year array, and then you can plot against this array.
In your case, I did this:
yfrac = yyyymmdd_to_yyyyfrac (toint(date),0)
and then plotted against yfrac.
2. Once you've done #1, then labeling the X axis would look something like
this:
mmdd = str_get_cols(date,4,5) + "/" + str_get_cols(date,6,7)
resL at tmXBMode = "Explicit" ; explicit labels
resL at tmXBValues = yfrac(::2) ; only label every other tick mark
resL at tmXBLabels
= mmdd(::2)
3. To avoid all of these warnings:
warning:tofloat: A bad value was passed to (string) tofloat, input strings
must contain numeric digits, replacing with missing value
which are occurring because you are trying to convert "" to a float, you
want to replace all the "" with missing values using str_sub_str, and then
convert it to float:
msg = default_fillvalue("float") ; 9.969212e+36
msg_str = "" + msg
sm_str = str_get_field(data_col(1:),3,delim)
sm = tofloat(str_sub_str(sm_str,"",msg_str))
sm at _FillValue = msg
4. When plotting two curves in the same space that have different ranges,
you have to be very careful about setting the trX/Y/Min/MaxF resources. NCL
is effectively taking two individual XY plots and drawing them on top of
each other, so if you change the trYMaxF for one and not the other, then
the curves from both plots are not going to be quite lined up properly. I
fixed this by setting these values to the actual min/max of your data.
5. Since your prec array has a lot of isolated values, it might be best
plotted as a series of markers (resR at xyLineMode = "Markers") instead of
curves. When you plot curves, you will not see the single isolated values.
You can also plot as both markers and curves (resR at xyLineMode = "MarkLines")
See the attached script.
--Mary
On Tue, Oct 2, 2018 at 3:05 AM, Ehsan Taghizadeh <ehsantaghizadeh at yahoo.com>
wrote:
> Hi,
> I tried to plot something like "requested.png" in attached files. My input
> data are "data.txt". I've prepared attached ncl script "meteogram2.ncl".
> However its output "GPM_SMAP_20170401_30.png" has some problems.
> First its "sm" data are not shown correctly.
> Second I want its x bottom tickmarks string (/'04/01', '04/03',
> ...,'04/03'/). However as I understood x label in "gsn_csm_xy2" could be
> numeric only!
> Third y right axis should be displayed 2 digit after floating point.
>
> I'll be thankful if I could have any help or reference about them.
>
> Sincerely
> Ehsan
>
> _______________________________________________
> 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/20181002/124f7623/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: GPM_SMAP_20170401_30.png
Type: image/png
Size: 74026 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20181002/124f7623/attachment.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: meteogram2_mod.ncl
Type: application/octet-stream
Size: 3649 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20181002/124f7623/attachment.obj>
More information about the ncl-talk
mailing list