xforms-development
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [XForms] axes coords in XYPlot


From: Michal Szymanski
Subject: Re: [XForms] axes coords in XYPlot
Date: Thu, 19 May 2011 23:16:02 +0200
User-agent: Mutt/1.4.2.2i

> > 
> > What I want to get are the coordinates (be it screen or "world" - the above
> > mentioned routines allow to convert between the two systems) of the corners
> > of the plot where the axes cross (well, they do not actuall cross, but
> > contact each other).
> 
> Mmm, another idea: when I do
> 
>     float llc_x, llc_y, urc_x, urc_y;
>     float min_x, max_x, min_y, max_y;
> 
>     fl_get_xyplot_xbounds( obj, &min_x, &max_x );
>     fl_get_xyplot_ybounds( obj, &min_y, &max_y );
> 
>     fl_xyplot_w2s( obj, min_x, min_y, &llc_x, &llc_y );
>     fl_xyplot_w2s( obj, max_x, max_y, &urc_x, &urc_y );
> 
>     printf( "llc: %f %f, urc: %f %f\n", llc_x, llc_y, urc_x, urc_y );
> 
> (where "llc" stands for lower left hand corner and "urc" for upper
> right hand corner) the result look rather like the screen coordi-
> nates of these points, i.e. the corners of the axes-systems in the
> coordinate system of the xyplot object. And I get the same results
> when I do instead
> 
>     float ax, bx, ay, by;
> 
>     fl_get_xyplot_xmapping( obj, &ax, &bx );
>     fl_get_xyplot_ymapping( obj, &ay, &by );
> 
>     printf( "llc: %f %f, urc: %f %f\n", bx, by,
>             ax * ( max_x - min_x ) + bx,
>             ay * ( max_y - min_y ) + by );
> 
> And if you just want the "world" coordinates of the "edges"
> fl_get_xyplot_xbounds() and fl_get_xyplot_ybounds() alone
> should do the job.
> 
> Is this what you are looking for or am I still misunderstanding
> your question?

This might be (and probably is) true if one leaves to the library the
computing of data limits and ticks. If you, however, start to experiment
with fl_set_xyplot_[xy]bounds and fl_set_xyplot_[xy]ticks, the result
happens to be different.

I am able to reproduce the behavior of my bigger app using a test form
containing just a single XYPlot object (and EXIT button). The displaying
code is:

void init_objects(FD_test *ft, char *fname, double ymin, double ymax)
{
  float y1, y2;
  
  fl_set_xyplot_file(ft->xy, fname, "XYPlot", "X", "Y");
  fl_set_xyplot_ytics(ft->xy, 5, 1);
  if (ymin || ymax) {
    fl_set_xyplot_ybounds(ft->xy, ymin, ymax);
  }
  fl_get_xyplot_ybounds(ft->xy, &y1, &y2);
  printf("%f %f\n", y1, y2);
}

called from test_main.c with a file name and (optionally ymin/ymax, set to
0.0 by default).
The file contains data spanning (in the second column, Y) from 13.523 to
17.226. 

When invoked w/o forced ymin/ymax, the plot spans in Y from 13.0 to above
17, and the bounds "got" from library are:
13.523000 17.226000 - the upper seems OK but the lower is shifted by 0.5
from the real axes.

When invoked with example ymin/ymax of 13.34 17.41, the Y axis spans
from 13.0 to 18.0 (sharp) but the ybounds "got" from library are (obviously
same as "set")
13.340000 17.410000 - both pretty different than actual axis limits.

So, I would opt for a routine that would get the real axes limits (corners
coords), no matter how the plot was constructed (bounds, ticks, etc.)

regards, Michal.

-- 
  Michal Szymanski (msz at astrouw dot edu dot pl)
  Warsaw University Observatory, Warszawa, POLAND



reply via email to

[Prev in Thread] Current Thread [Next in Thread]