Link to home
Start Free TrialLog in
Avatar of rocco
rocco

asked on

Plot Axis Algorithm

I am looking for a "good" algorithm that given a
arbitrary data range, will return a "good" data
range and "good" tick intervals?
Avatar of pc012197
pc012197

Specify "good", "good" and "good".

ASKER CERTIFIED SOLUTION
Avatar of Slarti
Slarti

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ozo
Is this "good"?

#define ticks 6
interval(int min, int max){
          int i,n,t;
          n = max-min;
          t = n/ticks;
          i = 1;
          while( i*10<t ){ i *= 10; }
          if( i*5 < t ){ i *= 5; }
          if( i*2 < t ){ i *= 2; }
          for( t=min-(min%i+i)%i; t < max; t+= i ){
                    printf("%d ",t);
          }
                printf("%d ",t);
}