How to map logarithmic scale onto linear space?

1k Views Asked by At

I'm dealing with samples with values in $[0,1]$. I'd like to display them on a semi log scale, since the values between $0$ and $0.5$ are more interesting, than $0.5$ and above. Precision is 32 bit float.

I can't figure how to map them on a log scale, where the x-axis is the sample number, and the y-axis the value, on a logarithmic scale. Or rather, how to map a log scale onto regular 2D space, since I'll be painting the points on the graph myself.

To clarify: let's assume the output display is 100 pixels in height, value $0$ would be painted on pixel 0, a value of $0.1$ on pixel 50 and a value of $1.0$ on pixel 99.

I kinda have had this knot in my brain for the entire day, and I can'f figure out how to map those values, since $\log_{10} 0 = -\infty$ and $\log_{10} 1 = 0$.

I feel like it's a very simple question, but I'm just can't find an answer, especially, since the values I need to display are $0.0$ to $1.0$.

The function I'm looking for, should ideally also map into $[0,1]$, so I can scale for the actual output display, etc.

So: $f(0) = 0; \; f(0.1) = 0.5; \; f(1.0) = 1.0$ .

Thanks in advance!

1

There are 1 best solutions below

0
On

You could simply plot the pairs $(x_i, f(y_i))$ with $f(y_i) = \frac{1}{2} \log_{10}(y_i) + 1$ instead of the original datapoints $(x_i, y_i)$, couldn't you? This would give $f(1) = 1$, $f(0.1) = 0.5$ and $f(0.01) = 0$. As you point out, mapping $0 \rightarrow 0$ in such a fashion is impossible. If your're set on a logarithmic scale, you will never be able to include 0 in it.