 # How to display 0 on a log-transformed y axis ?

Hi everyone !
On an actual dataset (that comports some point y = 0) where the values can be far from each other (especially for a category) I would like to represent them on a log-transformed axis (log10).
I correctly work with the next code :

``````ggplot(data, aes(x=organ, y=loadcox, fill=sex)) +
geom_dotplot(binaxis='y', stackdir='center', position=position_dodge(0.8)) +
scale_y_continuous(trans='log10')
``````

However, the point with y=0 are not display..
Can anyone already have the same issue ?
Is it because this function scale_y_continuous(trans) not allowed the 0 (due to the fact that log(0) is not defined) ?

It makes sense to me that if as you say log(0) is undefined, then it is not going to be plotable

you could fake it, but it wouldnt be 'true'

``````library(tidyverse)
data <- iris %>% select(Sepal.Length,Sepal.Width,Species)
## add some zeros to Sepal.Width
data <- bind_rows(data,
data.frame(Sepal.Length=6.5,
Sepal.Width=0,
Species="virginica"))

ggplot(data, aes(x=Sepal.Length, y=Sepal.Width, fill=Species)) +
geom_dotplot(binaxis='y', stackdir='center', position=position_dodge(0.8)) +
scale_y_continuous(trans='log10' , limits = c(10^-4,5) , breaks=c(10^-4,1:5),
labels=c(0,1:5))
``````

Where would you expect it to be plotted?
Zero is near 10e-10 and therefore it should be plotted near -10,
but also near 10e-20 and therefore ...
Use a different transformation e.g log(1+x)

The data transformation by log(0.001 +x) worked ! Thank you !
By I think the data are tricky anyway to correctly to visualize because indeed the majority is very small and the others are very large.
Thanks everyone !

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

When I directly transformed my data and plot I agree, as 0 is not defined it is not display.
But with the axis transformation I expected that only the presentation of my data was changed and so the 0 was not affected and could be correctly plot.
I clearly see the differences on the y axis value between the log transformation of my data (values : -10 -> 0) and the transformation of the axis (values : 0.00005 -> 0.2).

I tried a log(1+x) transformation. Here the 0 were plot but I loose the interest of a data transformation because the plot looked very similar to the one without transformation, the data were squashed due to the high values.

what scale are your values ? are they small before the transform so that '1' is relatively large against them ?
transform by log(0.001 + x) ... ?