Hi Nicolas,
The fill_between.jnl script uses two variables which can be drawn
as simple line plots, and creates lists of points to use in a
POLYGON command. So you're right, it doesn't work because what
you are plotting is two sets of numbers as a PLOT/VS scatter
plot.
Instead we can just use the POLYGON command directly. I'll show
this as the polygon command can be a biti obscure, and at least I
was unfamiliar with what a violin plot is, though now that I see
it I get why it's called that.
Make lists of all of the vertices using XCAT
...
let xvert = XCAT(pdfstat, -1*pdfstat)
let yvert = XCAT(hval,hval)
polygon/line/pal=blue/hlim=-0.04:0.04/vlim=-1:80 xvert,yvert
(first image)
The only thing remaining is to remove the line down the center -
unless you want that. The XCAT definitions above wind up drawing
from the end of the first curve to the start of the next one. So
reverse the order of the second lists before doing the XCAT:
let xvert = xcat(pdfstat, -1*pdfstat)
let yvert = xcat(hval,hval)
frame/file=plot1.png
let r_hval = XREVERSE(hval)
let r_pdfstat = XREVERSE(pdfstat)
let xvert = xcat(pdfstat, -1*r_pdfstat)
let yvert = xcat(hval, r_hval)
polygon /line/pal=blue/hlim=-0.04:0.04/vlim=-1:80 xvert,yvert
(2nd image)
On 5/22/2017 5:32 AM, Nicolas Freychet
wrote:
hi again,
So I managed to do something, but I still need one extra
step to get the good plot.
So for instance I have a list like that:
let list1 = {0,40,24,15,10,0,0,57,63,14,16,80,10,20,0,0,0,0,0}
!!Compute pdf stats:
LET hsort = SAMPLEI(XSEQUENCE((list1)),
SORTI(XSEQUENCE((list1)) ))
LET ns = `hsort[i=@ngd]`
LET hval = hsort[i=1:`ns`]
LET hcount = i[gx=hval,i=1:`ns`]
LET hpdf =
2/((hval[i=@shf:+1]-hval[i=@shf:-1])*hcount[x=@max])
let pdfstat=if hpdf then hpdf else 0 !!!!change masked values
to 0
Then I can do a violin plot-type simply with that:
plot/vs/line=1/hlim=-0.04:0.04/vlim=-1:80 pdfstat,hval
plot/vs/line=1/hlim=-0.04:0.04/vlim=-1:80 pdfstat*-1,hval
Now the problem is I'd like to fill the space between
the 2 curves.
I tried to use the fill_between function but it seems
that the axes are wrong, probably because it's a versus
plot.
GO fill_between
POLY/Pattern=lite_vertical/OVER/NOLABEL/PALETTE=blue
pdfstat*-1 pdfstat*-1 pdfstat
But I have the error "dimensions improperly specified"
Nicolas
|