> From: David Vincent-Jones <[EMAIL PROTECTED]>
>
> Just to confirm:
>
> Applying text within a plot routine has a problem
> pd 'text 0 -20x test 1 2 3'
>
> prints/displays as
> text1 2 3
>
> This makes it difficult to add a table into any plot.
Stripping white space is a common practice,
such HTML normalization. Instead nbsp is used.
For a table, monospace font is needed.
nbsp_z_=: 1 :'(2*m)$194 160{a.'
pd 'text 0 -20x test',6 nbsp,'1',6 nbsp,'2',6 nbsp,'3'
Here's a helper table builder verb
that will take initial position, list of column widths,
line height and a table of values. The result will be
a series of 'text ...' with corresponding positions.
NB.*pdtable v plot text from table
NB. (XY;colwidths;lineheight) pdtable table
NB. eg: pd (10 _60;0 40 80;_18) pdtable i.2 3
pdtable=: 4 : 0
'pos cw lh'=. x
r=. ''
for_Y. ({:pos)+lh*i.{.$y do.
for_X. ({.pos)+cw do.
v=. ":(Y_index,X_index) {:: y
r=. r,'text ',(":X),'x ',(":Y),'x ',v,LF
end. end.
r
)
(10 _60;0 40 80;_18) pdtable i.2 3
text 10x _60x 0
text 50x _60x 1
text 90x _60x 2
text 10x _78x 3
text 50x _78x 4
text 90x _78x 5
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm