2016-10-20 17 views
1

データセットに0〜140の奥行きデータが含まれ、他の列にはいくつかのパーセンテージが含まれています。私はggplotとfacetを使ってデータをプロットし、軸の下のy軸(奥行き)のゼロを除いて素晴らしいものでした。私はこのゼロをy軸の頂点にしたい。ggplotとファセットの逆Y軸

これは例えばデータです:

log <- structure(list(Depth = c(5,10,15,20,25,30,35,40,45,50,55, 60,65,  70,75,80, 85,90, 95,100,105,110,115,120,125,130,135,140), mic1 = c(16.93548387,13.55932203, 6.034482759,33.6, 26.8907563, 51.47928994, 24.29906542,16.84210526, 26.14379085, 19.72318339,21.77419355,53.33333333,50.56179775,19.07514451,27.63819095, 25.6, 23.56687898, 19.04761905, 43.33333333,36.30952381,62.45059289,20.43010753,32.23140496,16.4021164,47.48201439,48.73646209,17.44186047, 39.04109589), mic2 = c(16.93548387, 13.55932203, 6.034482759,33.6, 26.8907563, 51.47928994, 24.29906542,16.84210526, 26.14379085, 19.72318339,21.77419355,53.33333333,50.56179775,19.07514451,27.63819095, 25.6, 23.56687898, 19.04761905, 43.33333333,36.30952381,62.45059289,20.43010753,32.23140496,16.4021164,47.48201439,48.73646209,17.44186047, 39.04109589)), .Names = c("Depth", "f1", "f2"), row.names = c(NA, 20L), class = "data.frame") 

私はバーでそれらをプロットするために、このコードを使用しています:

logMelt1 <- melt(log, id.vars="Depth") 
logm <- ggplot(logMelt1, aes(x=Depth, y=value)) + geom_bar(stat = 'identity') + coord_flip() + facet_grid(~ variable, scale ='free_x') 
logm 

as you can see the Depth axis start from the bottom

私はREVERSできる方法を知りたいです奥行き軸で0が上から始まるようにしますか?

答えて

1

多分試してみてください。

logm <- ggplot(logMelt1, aes(x=Depth, y=value)) + 
    geom_bar(stat = 'identity') + 
    scale_x_reverse() + 
    coord_flip() + 
    facet_grid(~ variable, scale ='free_x') 

軸を逆にしますか?

関連する問題