Re: OT: Determining the size of plotting area



Robert Singer <rsinger@xxxxxxxx> 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
.



Relevant Pages

  • Re: "scale" numbers?
    ... Is there some procedure to "scale" all the numbers to lie in the range ... let v' be the scaled vector into, and v" be an intermediate ... Depending on the application, you may want floor, ceiling, rounding, ... if you use the integer portion instead (which is the same as the ...
    (sci.math)
  • Re: Rounding
    ... Subtracting 0.0049 and then casting to DECIMAL with a scale of 2 will ... effectively truncate the third digit to the right of the decimal point: ... > All of the functions that I have tested, with regards to rounding, round ...
    (microsoft.public.sqlserver.programming)
  • Re: floats, doubles and maths
    ... Patricia Shanahan writes: ... choice for financial calculations that need two decimal place rounding ... is java.math.BigDecimal, with scale factor 2. ...
    (comp.lang.java.help)
  • Re: rounding
    ... Rounding .5625 to two places should result in .57 and rounding 6.125 to two places should result in 6.13, ... double RoundToMultiple(double num, double multiple) ... return Math.Round(num * scale) / scale; ... Note that if you pick something that is theoretically divisible into 1.0, but which is not representable in binary, you may wind up wind rounding error. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: VAT Rounding Question
    ... When I did Maths O and A levels the general *maths* rule for rounding ... The rule you recall is, if I recall rightly, a ... Robin ...
    (uk.business.accountancy)