> From: Sherlock, Ric
> 
> Some comments:
> Do you need to special case when edgecolor is _1 ? Could you just use
> an edgesize of 0 to get the same result? That simplifies your
> makedrawbar verb.

Actually I see now that without that special case handling it is exactly the 
same as the existing makedrawbar_jzplot_ verb and could therefore be left out 
of the script altogether:

NB.==========Custom Stacked Bar script==============================
require 'plot'

coclass 'pzplot'
coinsert 'jzplot'

NB.*typereg v register plot type (framework)
typereg=: 4 : 0
  ('plot_',y,'_jzplot_')=: ('plot_',y,'_',(>coname''),'_')~ f.
  for_i. x do.
    ((>i),'_jzplot_')=: (((>i),'_jzplot_')~ -. <y),<y
  end.
  PlotTypes_jzplot_=: ~. PlotTypes2d_jzplot_,PlotTypes3d_jzplot_

  empty''
)

plot_sbarn=: 3 : 0
'x y'=. 2 {. y { Data
dat=. citemize y
pos=. makestackbarn dat
pos makedrawbar dat
)

makestackbarn_jzplot_=: 3 : 0
'r c'=. $y
wid=. BARWIDTH
w=. Gw * wid % c
t=. Gw * -: (-.wid) % c 
o=. |YMin % YMax-YMin
uh=. (1-o) * Gh
lh=. o * Gh
m=. 0&<:y
y=. m (* ,: -...@[*]) y
y=. +/\."2 y
h=. (uh,lh) * y % YMax,|YMin
h=. (-.m)} h
y=. Gy + lh + ,h
x=. Gx + ($y) $ t + Gw * }: int01 c
x,.y,.(x+w),.y-,h
)

(;:'PlotTypes2d') typereg 'sbarn'

Note 'usage'
   'sbarn' plot (],:|.)@:(,|.@:-) i.5

   dat=: |:(+0.5-[:?0$~#)^:(<100) 0 _4 4 0
   pd 'new'
   pd 'type sbarn; edgesize 0; barwidth 1;xtic 10 2'
   NB. next 2 lines in lieu of getmin, getmax edits to jzplot.ijs
   minmax=. ({.@:<./ , {:@:>./) (0&< +//. ])@/:~"1 |:dat
   pd 'yrange ',": _2.5 2.5 <.@:+ minmax
   pd  dat
   pd 'type line;color 0 0 0; pensize 2;xtic 10 2'
   pd +/dat
   pd 'show'    
)
NB. ==========================================

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to