help-octave
[Top][All Lists]
Advanced

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

Re: Identify auto tick locations


From: tlhiv
Subject: Re: Identify auto tick locations
Date: Wed, 31 Oct 2007 15:46:08 -0700 (PDT)

Well folks,

After not getting a "good" answer, I decided to dig into GnuPlot's algorithm
for tick placement from its axis.c.  After some slight tweaking to
accommodate personal preferences, I came up with the following code for
computing these tick placements for x and y axes.

%%% This is for x tick placement %%%

xmin = min(x); xmax = max(x);
d = xmax - xmin;
power = 10^(floor(log10(d)));
dnorm = d/power;
posns = 20/dnorm;
if (posns > 40)
   tics = 0.05;
elseif (posns > 20)
   tics = 0.1;
elseif (posns > 10)
   tics = 0.2;
elseif (posns > 4) 
   tics = 0.5;
elseif (posns > 2) 
   tics = 1; 
elseif (posns > 0.5) 
   tics = 2; 
else
   tics = ceil(dnorm);
end
d = tics*power;
xticks = [ceil(xmin/d)*d:d:floor(xmax/d)*d];



%%% This is for y tick placement %%%

ymin = min(y); ymax = max(y);
d = ymax - ymin;
power = 10^(floor(log10(d)));
dnorm = d/power;
posns = 10/dnorm;
if (posns > 40)
   tics = 0.05;
elseif (posns > 20)
   tics = 0.1;
elseif (posns > 10)
   tics = 0.2;
elseif (posns > 4) 
   tics = 0.5;
elseif (posns > 2) 
   tics = 1; 
elseif (posns > 0.5) 
   tics = 2; 
else
   tics = ceil(dnorm);
end
d = tics*power;
yticks = [floor(ymin/d)*d:d:ceil(ymax/d)*d];
-- 
View this message in context: 
http://www.nabble.com/Identify-auto-tick-locations-tf4721491.html#a13520183
Sent from the Octave - General mailing list archive at Nabble.com.



reply via email to

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