From: Emmanuel P. <emm...@un...> - 2000-12-13 10:19:04
|
I'm not sure this is not implemented in the current GtkExtra API, but I use the following function to calculate a space between two ticks which is easily readable (ie: every 1Ex, 2Ex, 5Ex) void auto_tick_step ( int tick_count, double minimum, double maximum, double* major_tick_step, int *minor_tick_number) { double log_tick_step,test_tick_step,round_log_tick_step,round_tick_step; log_tick_step=log10(fabs(maximum-minimum)/(double) tick_count); test_tick_step=log_tick_step-floor(log_tick_step); round_log_tick_step=0.0; if ((test_tick_step>0.0)&&(test_tick_step<=log10(2))) { round_log_tick_step=log10(2); *minor_tick_number=9; } if ((test_tick_step>log10(2))&&(test_tick_step<=log10(5))) { round_log_tick_step=log10(5); *minor_tick_number=4; } if ((test_tick_step>log10(5))&&(test_tick_step<=log10(10))) { round_log_tick_step=log10(10); *minor_tick_number=9; } round_tick_step=exp((round_log_tick_step+floor(log_tick_step))*log(10)); *major_tick_step=round_tick_step; } params: tick_count : the maximum number of ticks. minimum and maximum : min/max of the axis. returns: major_tick_step : step between two ticks. minor_tick_number : number of minor ticks between two major ticks. example: tick_count=10 minimum=810 maximum=1200 -> major_tick_step=50 minor_tick_number=4 If a similar function does not exist, it would be great if it should bet implemented in GtkExtra. Emmanuel. |