Hello again,

I was asking a while ago about placing text on a plot at positions
specified in "graph coordinates". The example I gave wasn't very
useful. My novice tacit expressions are probably more complex than
they need to be, and I didn't give you any sample data. Sorry. I was a
bit too lost in my own problems to see the obvious simplification,
identical in all important respects, which is as follows.

Consider the following simple plot:

   X =. 0 1 2 3
   Y =. 3 2 1 0
   pd 'reset'
   pd 'type dot'
   pd X;Y
   pd 'show'

Given a list of boxed strings T with the same number of elements as X and Y:

  T =. 'label1';'label2';'label3';'label4'

I would like to draw those strings on the plot at the coordinates
given by X and Y, such that they label the dots that the above snippet
plots. Is this possible?

I looked into getting the plot geometry from the locale variables Gx
etc, but I think these are only assigned when "pd 'show'" is given.

I've worked out I can get one character towards what I am after by
using the "symbol" plot type, but I'd rather have a string located
relative to the point in question, as a label rather than a marker.

Thanks for any help,
Hamish

On Fri, Dec 5, 2008 at 22:59, Hamish Harvey <[email protected]> wrote:
> Thanks Björn, but I'm afraid I don't follow. Sorry if I'm missing
> something obvious.
>
> What I have is this:
>
> data =. ((1.5e8 * i. 5) ; 0 8 12 14 14) ,: (1.6e8 * i. 5) ; 0 9 14 16 16
> coords =. (>./&>@:{.@:] , >./&>@:{:@:])"1 data
> labels =. 'label 1'; 'label 2'
> pd 'reset'
> pd"1 data
> pd"1 (<. 1000 * 7e8 18 %~"(1) 0.25e8 1 +"1 coords) ('text ', ":@:[ , '
> '&,@:>@:])"(1 0) labels
> pd 'show'
>
> The "coords" line finds the end point of each line in "data". The
> second from last line then constructs a string 'text x y label',
> taking labels from "labels" and coords from "coords", but adjusting
> the coordinates approximately to match the graph axis coordinate
> system. The scale and offset I judged by eye. Is there any way I write
> text directly in the axis coordinate system, or obtain the
> transformation data from pd?
>
> Cheers,
> Hamish
>
> On Fri, Dec 5, 2008 at 21:21, Björn Helgason <[email protected]> wrote:
>> http://www.jsoftware.com/svn/base/tags/j602a/plot/base/main/test1.ijs
>>
>> 2008/12/5 Hamish Harvey <[email protected]>
>>
>>> Hello,
>>>
>>> I'm enjoying getting to grips with J.
>>>
>>> I've just got to plotting some results, and I wonder if it is possible
>>> to draw text using pd at graph coordinates. The options seem to be in
>>> pixel or [0,1000] coordinate systems, both of which cover the full
>>> area of the window (or pdf bounding box). I want to label the end of
>>> plot lines, though.
>>>
>>> If not, is there any way to obtain the transformation from plot area
>>> coordinates to one of these other systems?
>>>
>>> As an example: I have a line on a plot that ends at, say, (1.3e7, 45),
>>> and want to place a label close to the end of that line.
>>>
>>> Thanks,
>>> Hamish
>>>
>>> --
>>> Hamish Harvey
>>> Research Associate, School of Civil Engineering and Geosciences,
>>> Newcastle University
>>> ----------------------------------------------------------------------
>>> For information about J forums see http://www.jsoftware.com/forums.htm
>>>
>>
>>
>>
>> --
>> Björn Helgason, Verkfræðingur
>> Fugl&Fiskur ehf,
>> Þerneyjarsundi 23, Hraunborgum
>> Po Box 127,801 Selfoss ,
>> t-póst: [email protected]
>> gsm: +3546985532
>> Landslags og skrúðgarðagerð, gröfuþjónusta
>> http://groups.google.com/group/J-Programming
>>
>>
>> Tæknikunnátta höndlar hið flókna, sköpunargáfa er meistari einfaldleikans
>>
>> góður kennari getur stigið á tær án þess að glansinn fari af skónum
>>         /|_      .-----------------------------------.
>>        ,'  .\  /  | Með léttri lund verður        |
>>    ,--'    _,'   | Dagurinn í dag                     |
>>   /       /       | Enn betri en gærdagurinn  |
>>  (   -.  |        `-----------------------------------'
>>  |     ) |        (\_ _/)
>>  (`-.  '--.)       (='.'=)
>>  `. )----'        (")_(")
>>
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
>>
>
>
>
> --
> Hamish Harvey
> Research Associate, School of Civil Engineering and Geosciences,
> Newcastle University
>



-- 
Hamish Harvey
Research Associate, School of Civil Engineering and Geosciences,
Newcastle University
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to