| Re: OT: Determining the size of plotting area |
|
 |
|
 |
|
 |
|
 |
Group: comp.lang.fortran · Group Profile
Author: nospamnospam Date: Sep 16, 2008 20:38
Robert Singer ____.com> wrote:
> As far as I know fortran has no intristics for rounding numbers, so
> that would be one part of the problem.
Sure it does. And that part is even a Fortran-specific question, so you
ger "credit" for being on topic after all. :-)
See such things as anint. You have to scale as needed to get the
appropriate rounding, but that's trivially doable. How to do things like
rounding has come up here more than once, with several answers. Anint is
one (or just plain aint, as you are probably talking about rounding
down, also known as truncation, or rounding up, instead of rounding to
nearest). Doing internal writes is another way.
For example, 5.*aint(x/5) should round down to a multiple of 5.
> I guess just determining the xmax and multiplying it by 1,1 and then
> rounding up could solve the dilemma, but I'm still interested to hear
> your opinion.
The rounding part is simple, per above.
I used to have some routines for doing auto scaling, from circa late
70's, but it would take a while to dig them up from my archives, and
they probably reflect restrictions that you wouln't have to stick by
anyway (we often used gridded paper, so the plot scaling was restricted
to grid spacing that matched the paper). They weren't particularly
complicated, though; it isn't like it would be hard to do from scratch.
I don't recall the routines as being much more than half a dozen
executable lines or so - maybe a dozen.
Without digging out the old code or spending too horribly much time
thinking about it... Start with the min and max. Throw zero into the
min/max computation if desired. (Sometimes one wants to force zero to be
included in the scale; other times one doesn't). Use a log10 to estimate
the appropriate scale from a predefined selection of acceptable scales.
Then check whether the actual min and max "work" with that scale (after
appropriate rounding). If they don't, then adjust to the next coarser
scale. You can probably guarantee that the next one would work.
That's just a very rough sketch of what I recall as the general
algorithm.
--
Richard Maine | Good judgement comes from experience;
email: last name at domain . net | experience comes from bad judgement.
domain: summertriangle | -- Mark Twain
|