Simon - we've started a project at NYCJUG along these lines though I have
yet to add a wiki page for the project itself.  Take a look at
http://www.jsoftware.com/jwiki/NYCJUG/2008-09-09#head-6e7a10cb775e5926446cce741610345806857c00to
see what's been done on this so far.

I'll take a look at your questions in more detail in a couple of days to see
if I have any relevant suggestions to your specific queries.  In the
meantime, please keep the list updated on whatever you find out as this is a
topic interesting to many of us.

Thanks,

Devon

On Wed, Sep 24, 2008 at 12:53 PM, Simon Gibbon <[EMAIL PROTECTED]>wrote:

> Having used plot to produce a range of graphics, I am now trying to add
> extra features interactively to the plots produced computationally i.e.
> clicking on the plot working out the co-ordinates and then adding a line or
> text to the existing plot without redrawing it.  Having I think read the
> excellent plot documentation I feel I am still missing something and would
> appreciate pointing the right direction.
> So my simplistic method is to tie a function to the right mouse button,
> this
> is demonstrated in the routine "testplot_plotspace_mbrdown" in the example
> code below.   This code draws a plot with a straight line and then when you
> right click on the graph it plots a vertical line where you have clicked.
>  However, this a hack having discovered the variables I need (XMIN, XMAX,
> YMIN, YMAX), not from the documentation but from looking at the namespace.
>
> So I have 3 questions:
> 1 is this a sensible way to do such interactive plotting (simple way),
> 2 Gxywh, Sxywh etc are well documented in the Wiki under the Plot / Layout
> Calculation page is there another similar variable which reports the user
> units of the maximum X and Y used in the actual plot as the XRANGE variable
> is the range of the data not the range over which the data is plotted.
> 3 is there a way to swap between YAXIS and Y2AXIS, as I would like to be
> able to get x and y user co-ordinates back from either scaling, currently
> it
> appears to lock the axis scaling (ymin, ymax) to the Y2AXIS as the last one
> used.
>
> Thanks, Simon
>
> require 'files plot strings jzplot'
>
> TESTPLOT=: 0 : 0
> pc testplot;
> xywh 0 0 269 222;cc plotspace isigraph;
> pas 6 6;pcenter;
> rem form end;
> )
>
> testplot_run=: 3 : 0
> wd TESTPLOT
> aa=: conew 'jzplot'
> PForm__aa=: 'testplot'
> PFormhwnd__aa=: wd 'qhwndp'
> PId__aa=: 'plotspace'
> wd 'pshow;'
> pd__aa (0.2+i.10);i.10
> pd__aa 'show'
> )
>
> testplot_close=: 3 : 0
> wd'pclose'
> )
>
> testplot_cancel_button=: 3 : 0
> testplot_close''
> )
>
> testplot_plotspace_mbrdown=: 3 : 0
> NB. Adds a vertical line where the cursor is right clicked
> NB. Capture the current system state
> tyx=: 0&".,sysdata
> NB. Store the co-ordinates of the cursor in screen units
> 'xscreen yscreen'=: 2{.tyx
> NB. Discover the size of the area where the graph is being plotted
> 'xscreenmin yscreenmin xwidth yheight'=: Gxywh__aa
> NB. Simplistically thought that I could get the x and y ranges
> NB. from the range of the x and y data
> 'xmin xmax'=. XRANGE__aa
> 'ymin ymax'=. YRANGE__aa
> NB. The data range is wrong as the plot chooses a more sensible
> NB. range for the axes
> NB. I found that XMIN and XMAX store the min and max of the X axis
> xmin=. XMin__aa
> xmax=. XMax__aa
> NB. So I can now correctly calculate the x co-ordinate in user units
> xuser=: xmin+(xmax-xmin)*(xscreen-xscreenmin)%xwidth
> NB. I can do the same for y co-ordinates but only for y2 axis
> NB. as YMIN__a and YMAX__a are set to y2, don't know how to get
> NB. yaxis values back
> NB. yuser=: ymax-(ymax-ymin)*(yscreen-yscreenmin)%yheight
> NB.pd__a 'yaxis'
> NB. Draw a vertical line where the cursor was pressed
> pd__aa (xuser,xuser);ymin,ymax
> pd__aa 'show'
> )
>
> testplot_run ''
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
>



-- 
Devon McCormick, CFA
^me^ at acm.
org is my
preferred e-mail
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to