A friend and I are working on a heatmap representing some population numbers. Initially we used a linear color scale by default. Then, because the numbers covered a wide range, I tried using a log color scale (as shown here). My friend said it obscured the data too much.

So I was wondering, is there a something in between ... some sort of continuum between linear scale and log scale? Can I drag a slider (so to speak) between linear and log scale? E.g. we might try "25% log and 75% linear".

I guess I could use a linear interpolation function like

f(x) = x + (log(x) - x) * L

where L is "loggishness," ranging from 0 to 1, to interpolate between a linear and a log scale.

I guess there's nothing wrong with that, but it seems ... I don't know, a bit "unnatural." Like it doesn't fit the nature of the log function. Is there a more natural way to do this?

On second thought, I could also try geometric interpolation between x and log(x). That seems to be a little more in keeping with the nature of logarithms, but ... I'm still not sure if it's "the" natural way to do it. I'm also wondering whether it would be visually misleading at all (assuming that we tell the reader what kind of scale we're using).

Am I wrong to try to display data on a somewhat/more/less loggish scale? I couldn't find anyone else talking about it on the web, but maybe I just didn't know what terms to search for.

  • 5
    $\begingroup$ One could consider the integral $\int x^\alpha \mathrm dx$ as $\alpha$ smoothly varies from $1$ to $-1$... $\endgroup$ Commented Feb 8, 2012 at 22:43
  • 5
    $\begingroup$ ... in other words, essentially $x^p$ for $p$ from $0$ to $1$. $\log x$ corresponds to the (scaled and translated) limit as $p \to 0+$, i.e. $\log x = \lim_{p \to 0} \frac{x^p-1}{p}$ for $x > 0$. $\endgroup$ Commented Feb 8, 2012 at 22:58
  • $\begingroup$ @J.M., I think I understand what you're saying, but when I plot the graphs of this function, it desn't seem to resemble a gradual ramp from linear to log. Probably I'm not doing something right... $\endgroup$
    – LarsH
    Commented Feb 8, 2012 at 23:38
  • 3
    $\begingroup$ @LarsH: $x^0/0$ is not defined. But if you consider $0<p\leq 1$, then you get a continuum of curves between $x-1$ and $\ln(x)$, going to $x-1$ as $p\nearrow 1$, and going to $\ln(x)$ as $p\searrow 0$. $\endgroup$ Commented Feb 8, 2012 at 23:46
  • 1
    $\begingroup$ Geometric interpolation is nothing more than arithmetic interpolation conjugated by logarithm and exponentiation, so is equally unnatural imo. $\endgroup$
    – John Jiang
    Commented Oct 19, 2015 at 16:01

1 Answer 1


The integral of $x^n$ for $n\ne-1$ is $x^{n+1}/(n+1)$ (plus a constant), and the integral of $x^{-1}$ is $\log x$, so in a sense $\log x$ acts like $x^0$. Let's say you want to map $x_0$ to $y_0$ and $x_1$ to $y_1$, and you want the values in between to be something in between



$$y=y_0+\frac{\log x-\log x_0}{\log x_1-\log x_0}(y_1-y_0)\;,$$

where the $x$ values might be population numbers and the $y$ values might be colour values. Then you can consider $\log x$ as the limit of $x^n/n$ as $n\to0$ and write


for arbitrary $n\in[0,1]$, where $n=0$ is understood to mean the limit as $n\to0$. Indeed, by l'Hôpital

$$\lim_{n\to0}\frac{x^n-x_0^n}{x_1^n-x_0^n}=\lim_{n\to0}\frac{\frac{\mathrm d}{\mathrm dn}\left(x^n-x_0^n\right)}{\frac{\mathrm d}{\mathrm dn}\left(x_1^n-x_0^n\right)}=\lim_{n\to0}\frac{x^n\log x-x_0^n\log x_0}{x_1^n\log x_1-x_0^n\log x_0}=\frac{\log x-\log x_0}{\log x_1-\log x_0}\;.$$

So the parameter $n$ is the slider you can slide from $0$ to $1$ to go from $\log x$ to $x$. You may have some precision issues to deal with as you get close to $n=0$, and you should make sure to handle the case $n=0$ separately using the actual $\log$ function.

Here's a plot for $y_0=0,y_1=1,x_0=1,x_1=10$ and $n=0,\frac14,\frac12,\frac34,1$.

  • 1
    $\begingroup$ The plot is very cool! I can see how it works with n. Also I will need to learn how to post links to Wolfram Alpha plots. $\endgroup$
    – LarsH
    Commented Feb 9, 2012 at 4:04
  • $\begingroup$ @Lars: It works just like for other links -- make the plot in Wolfram|Alpha, copy the URL from the browser's URL field, select the text with which you want to link and click the chain icon above the editor field. $\endgroup$
    – joriki
    Commented Apr 3, 2013 at 5:16
  • $\begingroup$ Remains the question how I tweak my favorite plot tool (Gnuplot or whatever) to place meaningful ticks and their values on the axes for values between linear and logarithmic … $\endgroup$
    – Alfe
    Commented May 16, 2017 at 9:54
  • 1
    $\begingroup$ You write, "in a sense $\log x$ acts like $x^0$", but shouldn't that rather be "like $x^0 / 0$"? And since this would be $1 / 0$ one could expect these values to tend to infinity (which they do) but $\log x$ is not. Since $\log 1$ is $0$, we know the integral constant to be $- 1 / (x+1)$, so we can use this function as an approximation for $\log x$: $x^0 / 0 - 1 / 0$ or in the case of $n$ not being exactly $-1$ but approaching it: $x^{(n+1)} / (n+1) - 1 / (n+1)$. $\endgroup$
    – Alfe
    Commented Jun 6, 2017 at 10:11
  • $\begingroup$ I don't see how you get from $\lim \limits_{n \to 0} \frac{\frac{d}{dn} (x^n - x_0^n)}{\frac{d}{dn} (x_1^n - x_0^n)}$ to $\lim \limits_{n \to 0} \frac{x^n {\log x} - x_0^n {\log x_0}}{x_1^n {\log x_1} - x_0^n {\log x_0}}$ $\endgroup$ Commented Aug 21, 2022 at 8:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .