A simple function useful to plot a logarithmic scale. Just provide it with the min and max values of the scale and the value you want to convert - and you'll get in return a value as it should be positioned on a logarithmic scale in the given range.
public double toLogScale(double min, double max,double val) {
double logmin = Math.log(min);
double logmax = Math.log(max);
double logscale = (Math.log(val)-logmin) / (logmax-logmin);
return min+(max-min)*logscale;
}
Comments