> From: Oleg Kobchenko <[EMAIL PROTECTED]>

> 
> This one and the other are good examples of making new plots from user
> commands. The use of custom marker is a step in the right direction. 
> 
> The problem with such use of pd is that it brings forward too much 
> implementation detail.
> 
> It would be good to be able to say
> 
>    'stocks' plot open,hi,lo,:close
> 
> I wonder if new plot types could be defined as addons, e.g.
>     load'graphics/plot/stocks'
> 
> This is an attribute of component design: you don't have to modify and 
> re-build the existing package.
> Another way of looking at it is pluggable framework.
>   
> 
> On Nov 23, 2008, at 15:56, "Sherlock, Ric" wrote:
> 
> ---Oleg Kobchenko wrote:
> From: "Hahn, Harvey" 
> Oleg Kobchenko
> |As in existing error bar and high-low types, I believe the
> |ticks should be drawn geometrically rather than placed as glyphs.
> 
> That makes far more sense for the general case with
> resizability.
> Since this thread interests me greatly, do you
> have any suggestions about how one goes about drawing these things

Here's an example of custom plot type.

NB. =========================================================

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''
)

NB. sample custom plot type (plugin)
plot_hilo2=: 3 : 0
  'x y'=. getgrafxy y
  'r c'=. $y
  clr=. getitemcolor 2
  hilo=. ,./x,."1 [ 2{.y
  drawline iDATA;({.clr);PENSIZE;hilo
  dx=. 0.33*-/1 0{x
  if. r>:3 do.
    close=. x,.(2{y),.(x+dx),.2{y
    drawline iDATA;({.clr);PENSIZE;close
  end.
  if. r=4 do.
    close=. (x-dx),.(3{y),.x,.3{y
    drawline iDATA;({.clr);PENSIZE;close
  end.
)

(;:'PlotTypes2d') typereg 'hilo2'

Note 'End-user code'
   HLCO=: (0 3 1 2&{@/:~)"1&.|: 4 30 [EMAIL PROTECTED] 100
   'hilo'  plot 3{.HLCO
   'hilo2' plot 3{.HLCO
   'hilo2' plot    HLCO
)
NB. =========================================================


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

Reply via email to