2012-10-05 25 views
2

在我已經翻轉座標和堆疊的比例吧,我想改變Y比例(現在在x刻度位置)不具有非顯著零的barplot:GGPLOT2刪除無意義的零

我嘗試:

ggplot(diamonds, aes(color, fill=cut)) + 
    geom_bar(position='fill') + coord_flip() + 
    scale_y_discrete(breaks = c(0, .25, .5, .75, 1), 
     labels=c("0", ".25", ".5", ".75", "1")) 

當前情節: enter image description here

+0

什麼是非重要零值? – Maiasaura

+0

@Maiasaura我希望'0.00,0.25,0.50,0.75和1.00'成爲'0,.25,.50,.75和1'。 –

回答

4

對於我來說,它的工作原理與scale_y_continuous

ggplot(diamonds, aes(color, fill=cut)) + 
geom_bar(position='fill') + 
coord_flip() + 
scale_y_continuous(breaks = c(0, .25, .5, .75, 1), 
        labels=c("0", ".25", ".5", ".75", "1")) 

enter image description here

+0

完美。回想起我以離散思維想到的是什麼? –