<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><div class="gmail_default" style="color: rgb(34, 34, 34); background-color: rgb(255, 255, 255); font-family: verdana, sans-serif;"></div><div class="gmail_default" style="color: rgb(34, 34, 34); background-color: rgb(255, 255, 255); font-family: verdana, sans-serif;">Alan.</div></div><div class=""><br class=""></div><div class=""><br class=""><div class=""><div><blockquote type="cite" class=""><div class="">On 30 Dec 2016, at 14:21, Guido Cioni <<a href="mailto:guidocioni@gmail.com" class="">guidocioni@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=us-ascii" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">I was going to reply with a similar recipe :) <div class=""><br class=""></div><div class=""><div class="">Basically, when drawing the line you have to split every segment and assign a color based on the average value of the y in that segment. </div><div class="">This is just an hint, you will have to complete the code.</div><div class=""><br class=""></div><div class="">Assuming you have <font face="Menlo" class="">x,y </font>which are your data values:</div><div class=""><br class=""></div><div class=""><font face="Menlo" class="">levels=fspan(min(y), max(y), 20) ; define the levels for the colors, you can change this but it will always depend on the number of segments</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class="">cmap = read_colormap_file("amwg_blueyellowred") ; define the colormap that you want to use</font></div><div class=""><br class=""></div><div class=""><div class=""><font face="Menlo" class="">do i=0,dimsizes(y)-1 ; loop over the segments</font><span style="font-family: Menlo;" class=""> </span></div><div class=""><font face="Menlo" class=""> res@xyLineColors=GetFillColor(levels,cmap,avg((/y(i),y(i+1)/)))</font></div><div class=""><font face="Menlo" class=""> gsn_polyline(wks,plot,(/x(i),x(i+1)/),(/y(i),y(i+1)/),lres) </font></div><div class=""><font face="Menlo" class="">end do</font></div></div><div class="">
<div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class="Apple-interchange-newline">Guido Cioni</div><div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="http://guidocioni.altervista/" class="">http://guidocioni.altervista</a>.org</div>
</div>
<br class=""><div class=""><blockquote type="cite" class=""><div class="">On 30 Dec 2016, at 17:35, Rick Brownrigg <<a href="mailto:brownrig@ucar.edu" class="">brownrig@ucar.edu</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class=""><div class=""><div class=""><div class=""><div class=""><div class=""><div class=""><div class=""><div class=""><div class="">Hi,<br class=""><br class=""></div>I don't know of any way of doing this other than to draw the line piecewise. What about something like:<br class=""><br class=""></div><div class="">datadims = dimsizes(data) ; assuming your data is 2xN<br class=""></div>numlinesegs = datadims(1) - 1<br class=""></div><div class="">linesegs = new((/ numlinesegs/), graphic)<br class=""></div>do i=1,numlinesegs<br class=""></div> color = ....appropriate logic to determine the color here...<br class=""></div> res@gsLineColor = color<br class=""></div> linesegs(i) = gsn_add_polyline(wks, plot, data(0, i-1:i), data(1, i-1:i), res)<br class=""></div>end do<br class=""><br class=""></div>This is not particularly efficient, and there may be better ways of doing this, but that should work.<br class=""><br class=""></div>HTH...<br class=""></div>Rick<br class=""><br class=""></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Fri, Dec 30, 2016 at 12:48 AM, grace <span dir="ltr" class=""><<a href="mailto:313695096@qq.com" target="_blank" class="">313695096@qq.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="">Hi:</div>
<div class=""> All,I am trying to draw a line that emphasize every parts of it with different colors.</div>
<div class="">I have found the example xy_12.ncl which highlight the wanted part by split the data.</div>
<div class="">But I want to draw a line which have different colors according to its y numberical value,just like the plot below.</div>
<div class=""><span id="cid:0356412F@5DA70B25.65116658.png" class=""><0356412F@5DA70B25.65116658.png></span></div>
<div class="">If I split the data ,that would be a huge work.</div>
<div class="">Have anybody drawed plot like this ?Any information will be appreciated.</div>
<div class=""> </div>
<div class=""><span style="LINE-HEIGHT:23px;FONT-FAMILY:'lucida Grande',Verdana,'Microsoft YaHei'" class=""></span> </div>
<div class=""></div><br class="">______________________________<wbr class="">_________________<br class="">
ncl-talk mailing list<br class="">
<a href="mailto:ncl-talk@ucar.edu" class="">ncl-talk@ucar.edu</a><br class="">
List instructions, subscriber options, unsubscribe:<br class="">
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank" class="">http://mailman.ucar.edu/<wbr class="">mailman/listinfo/ncl-talk</a><br class="">
<br class=""></blockquote></div><br class=""></div>
_______________________________________________<br class="">ncl-talk mailing list<br class=""><a href="mailto:ncl-talk@ucar.edu" class="">ncl-talk@ucar.edu</a><br class="">List instructions, subscriber options, unsubscribe:<br class=""><a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" class="">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br class=""></div></blockquote></div><br class=""></div></div>_______________________________________________<br class="">ncl-talk mailing list<br class=""><a href="mailto:ncl-talk@ucar.edu" class="">ncl-talk@ucar.edu</a><br class="">List instructions, subscriber options, unsubscribe:<br class="">http://mailman.ucar.edu/mailman/listinfo/ncl-talk<br class=""></div></blockquote></div><br class=""></div></div></body></html>