[ncl-talk] issue with gsn_add_polygon
Adam Herrington
adam.herrington at stonybrook.edu
Fri Jun 12 19:58:42 MDT 2020
I'm attempting to compute a raw violin-type plot. This is similar to a box
plot, but I'm drawing a polygon around the pdf, and I close the polygon
through a mirror image (-1*probability). Then I rotate it so it's vertical,
and align it with the x-axis "id" of the box plot.
If you're not following, I don't blame you ... this is hard to describe.
Attached is my attempt at this that will hopefully clarify what I'm trying
to do.
**digression before I go on to details on my primary issue**
I'd like to experiment with an actual violin plot, with a smoothed kernel
density estimate of the distribution. The routine kde_n_test
<https://www.ncl.ucar.edu/Document/Functions/Built-in/kde_n_test.shtml> should
work, but the warnings on the ncl page say the function is under
construction. Is that the latest update for this function?
**end digression**
You'll notice for panels 2 and 3 there is a line pivoting from the bottom
of the pdf's to the (0,0) point on the plot. I'm having trouble tracking
down why this occurs and how to fix it. I'm going to copy-paste the
relevant portions of the code for one of the x-value id's.
dx = 0.4d0 ;; x-depth of the pdf
xvals = (/1.,2.,3.,4.,5.,6./) ;; case id
...
pdfib = pdfx(ibdiff,nbins,optpdf)
pdfib = pdfib/max(pdfib)
xib = new( (/2*nbins/), "double")
yib = new( (/2*nbins/), "double")
xib(0:nbins-1) = xvals(n) - dx*pdfib
xib(nbins:2*nbins-1) = xvals(n) + dx*pdfib(nbins-1:0)
yib(0:nbins-1) = pdfib at bin_center
yib(nbins:2*nbins-1) = pdfib at bin_center(nbins-1:0)
pgstr = unique_string("dum")
plot@$pgstr$ = gsn_add_polygon(wks,plot(0),xib,yib,respg)
I am pretty sure the xib and yib are a closed contour.. they go from
0:nbins-1 and then nbins:2*nbins-1 ... Would like to get another set of
eyes on this though
thanks,
Adam
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20200612/c80569a9/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: temp_violens_clm.png
Type: image/png
Size: 485281 bytes
Desc: not available
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20200612/c80569a9/attachment-0001.png>
More information about the ncl-talk
mailing list