Jsoftware
High-Performance Development Platform

Text in a plot

View: New views
6 Messages — Rating Filter:   Alert me  

Text in a plot

by davidvincentjones :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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.

David

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

Re: Text in a plot

by Raul Miller-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Wed, Aug 27, 2008 at 3:58 PM, David Vincent-Jones
<davidvj@...> wrote:
>        pd 'text 0  -20x test      1      2     3'
> prints/displays as
>        text1 2 3

Are you looking for something like

   pd 'text 0  -20x test . . 1 . . 2 . . 3'

?

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

RE: Text in a plot

by Sherlock, Ric :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

---David Vincent-Jones
> 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.

You could do:
   pd 'text   0 -20x test'
   pd 'text  80 -20x 1'
   pd 'text 160 -20x 2'
   pd 'text 240 -20x 3'
   pd 'show'

For I table using non-monospace fonts, I imagine that you might need to use a method like this to get the columns to line up anyway?
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

RE: Text in a plot

by davidvincentjones :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Thanks Ric;

That should do the trick

It just appeared strange that pd lost all of the spaces in its output.

David

On Thu, 2008-08-28 at 09:09 +1200, Sherlock, Ric wrote:

> ---David Vincent-Jones
> > 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.
>
> You could do:
>    pd 'text   0 -20x test'
>    pd 'text  80 -20x 1'
>    pd 'text 160 -20x 2'
>    pd 'text 240 -20x 3'
>    pd 'show'
>
> For I table using non-monospace fonts, I imagine that you might need to use a method like this to get the columns to line up anyway?
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm

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

Parent Message unknown Re: Text in a plot

by Oleg Kobchenko :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> From: David Vincent-Jones <davidvj@...>
>
> 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

Re: Text in a plot

by davidvincentjones :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Oleg;

Lots to think about .. and many thanks the information is most helpful.

David


On Wed, 2008-08-27 at 21:33 -0700, Oleg Kobchenko wrote:

> > From: David Vincent-Jones <davidvj@...>
> >
> > 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

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
LightInTheBox - Buy quality products at wholesale price!