Ggplot2 0.9.1: Y-axis logarithmic scale with barcode

I am trying to convert the y axis of a chart to a logarithmic scale (Ie the logarithmic distance between each tick).

Some dummy data:

DF <- data.frame(num=c(1,2,3),label=c("a","b","c"))

I tried the following examples:

p <- ggplot(data=DF,aes(x=label,y=num)) + geom_bar() +
  scale_y_continuous(trans = 'log10',
                     breaks=trans_breaks("log10",function(x) 10^x),
                     labels=trans_format("log10",math_format(10^.x)))

This log only converts labels, but not check marks:

p <- ggplot(data=DF,aes(x=label,y=num)) + geom_bar() + coord_trans(y="log10")

This does not mean anything:

p <- ggplot(data=DF,aes(x=label,y=num),y="log")

Bad luck:

I also read the 0.9 transition guide , but that doesn't work either.

EDIT:

I forgot to include one example that I tried:

p <- ggplot (data = DF, aes (x = label, y = num)) + geom_bar () + scale_y_log10 ()

Which causes the following warning:

Warning message: In pretty (trans (x), n, ...): NaNs fired

0
source share
1 answer

if you want to use log scale 10

p + scale_y_log10()
+7
source

All Articles