<div dir="ltr">This is a little different to the version boxplot function Dennis put together but I wanted to do the same a while back so made this procedure. Rather than drawing it's own plot the function will add a box to an existing plot. So in the example you sent, you'd have the xy line plot and then you'd have to loop over this a lot of times, but it would get the job done. <div><br></div><div>As you can probably see everything is polylines so res takes standard gsLine* resources the two extra resources I had, were box_width to determine in plot units how wide the box should be. Also whisker_end as a logical to choose whether your want a line at the end or just leave it. <br><div><br></div><div>Let me know if you have issues with this if you do loop many times. I've found elsewhere that unique_string() starts to slow down significantly if called hundreds+ times. </div><div><br></div><div>Alan. </div><div><br></div><div><pre style="margin-top:0px;margin-bottom:0px;padding:0px;font-family:Consolas,Menlo,'Liberation Mono',Courier,monospace;font-size:12px;line-height:1.4;color:rgb(51,51,51)"><a name="cl-33" style="color:rgb(53,114,176)"></a><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<span class="">undef("add_boxplot_vertical")<br></span><span class="">procedure add_boxplot_vertical(wks, plot, xIn, yIn, res)<br></span><span class="">local xIn, yIn, res, x, nx, frac_limits, ind_limits, limits, box_width<br></span><span class="">begin</span>
<span class="">if(res.eq.True .and. isatt(res, "box_width"))<br></span><span class="">box_width = res@box_width <br></span><span class="">else<br></span><span class="">box_width = 1.<br></span><span class="">end if</span>
<span class="">y = yIn<br></span><span class="">qsort(y)<br></span><span class="">ny = num(.not.ismissing(y)); dimsizes(yIn) only account non missing data. <br></span><span class=""><br></span><span class="">frac_limits = (/0.1, 0.25,0.5, 0.75, 0.9/) ; percentiles for whisker , box, mid line, box, whisker.<br></span><span class="">ind_limits = toint( (frac_limits * ny) - 1) > 0</span>
<span class="">limits = y(ind_limits)<br></span><span class=""><br></span><span class="">plot@</span><span class="">$</span><span class="" style="color:rgb(0,128,128)">unique_string</span><span class="">(</span><span class="" style="color:rgb(187,136,68)">"line"</span><span class="">)$</span><span class=""> = gsn_add_polyline(wks, plot,(/xIn, xIn/), (/limits(0), limits(1)/), res)<br></span><span class="">plot@</span><span class="">$</span><span class="" style="color:rgb(0,128,128)">unique_string</span><span class="">(</span><span class="" style="color:rgb(187,136,68)">"line"</span><span class="">)$</span><span class=""> = gsn_add_polyline(wks, plot,(/xIn, xIn/), (/limits(3), limits(4)/), res)<br></span><span class="">plot@</span><span class="">$</span><span class="" style="color:rgb(0,128,128)">unique_string</span><span class="">(</span><span class="" style="color:rgb(187,136,68)">"line"</span><span class="">)$</span><span class=""> = gsn_add_polyline(wks, plot, (/xIn-box_width, xIn+box_width/), (/limits(2), limits(2)/), res)<br></span><span class="">plot@</span><span class="">$</span><span class="" style="color:rgb(0,128,128)">unique_string</span><span class="">(</span><span class="" style="color:rgb(187,136,68)">"line"</span><span class="">)$</span><span class=""> = gsn_add_polyline(wks, plot, (/xIn-box_width, xIn+box_width, xIn+box_width,xIn-box_width,xIn-box_width /), (/limits(1), limits(1),limits(3), limits(3), limits(1)/), res)</span>
<span class="">if(res.eq.True .and. isatt(res,"whisker_end") .and. res@whisker_end.eq.True)<br></span><span class=""> plot@</span><span class="">$</span><span class="" style="color:rgb(0,128,128)">unique_string</span><span class="">(</span><span class="" style="color:rgb(187,136,68)">"line"</span><span class="">)$</span><span class=""> = gsn_add_polyline(wks, plot, (/xIn-box_width, xIn+box_width/), (/limits(0), limits(0)/), res)<br></span><span class=""> plot@</span><span class="">$</span><span class="" style="color:rgb(0,128,128)">unique_string</span><span class="">(</span><span class="" style="color:rgb(187,136,68)">"line"</span><span class="">)$</span><span class=""> = gsn_add_polyline(wks, plot, (/xIn-box_width, xIn+box_width/), (/limits(4), limits(4)/), res)<br></span><span class="">end if</span>
<span class="">return<br></span><span class="">end</span></blockquote><a name="cl-35" style="color:rgb(53,114,176)"></a></pre></div><div><span class=""><br></span></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Mar 13, 2015 at 5:27 PM, Michael Mills <span dir="ltr"><<a href="mailto:mmills@ucar.edu" target="_blank">mmills@ucar.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">I would like to create a plot similar to that attached. I have investigated the boxplot routine, and it seems to only work for vertical boxes, plotted against the horizontal axis. Has anyone developed a routine to do the same for horizontal boxes plotted against the vertical axis?<div><br></div><div>Mike Mills</div><div>NCAR<div><img height="458" width="542" src="cid:A6648AAC-79D9-4BFB-9826-593D91B52F13@acd.ucar.edu"></div></div></div><br>_______________________________________________<br>
ncl-talk mailing list<br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>