Because the y values are too small, I need to use a log scale for y axis to show the differences. In the data, some entries do not have any value (0). Is there any way to show \
I found myself doing something similar although also completely different. For people who has stumbled here what I did might be of some use perhaps.
I had the problem that I had very large numbers that I wanted to show on a logarithmic scale but also some zeros. I went with a barplot and used NA for the 0s. It turns out that NA is left as empty space which I think makes sense in this case. I made an example of only 10 numbers but R seems to handle scaling for more values quite good:
values<-c(100000, 100, 2, 5, NA, NA, 2, 1, NA, 1)
barplot(values, names=1:length(values), log="y")
Choose some minimum value, and use that to represent 0:
m <- min(y[y!=0])/10
plot(x, pmax(y, m), log="y")
If I understand your question correctly, what you want is 0 (zero) just to show on the y axis
How about this
y=c(0.1, 0.001, 0.00001, 0.0000001, 0.000000001, 0.0000000001)
x=c(1, 2, 3, 4, 5, 6)
plot(x, y, log="y",yaxt="n")
axis(2,at=c(0.1, 0.001, 0.00001, 0.0000001, 0.000000001, 0.0000000001) ,labels=c(0.1, 0.001, 0.00001, 0.0000001, 0.000000001,"0"))
in plot
yaxt="n"
disables the drawing of the yaxis
then i manually draw a y axis with axis
and set the ticks
location with the at
argument. Then I set the lowest value i have (in your case 0.0000000001) to the character "0"
(at the label
argument)