2
我無法按我的方式格式化我的y軸標籤。我希望他們四捨五入到最接近的千位。如何使用ggplot中的對數刻度來格式化我的標籤
library(scales)
library(ggplot2)
df<-data.frame(x=seq(1,10,by=1),y=sample(10000000,10))
ggplot(df,aes(x=x,y=y))+geom_point()+scale_y_continuous(trans='log10', breaks=trans_breaks('log10', function(x) 10^x), labels=comma)
如何格式化我的Y標誌,以便他們四捨五入到最接近的千?換句話說,我想顯示7,943,000而不是7,943,282。
你可以試試'Y2 = signif(y,3)'將數字四捨五入到最接近的千位,然後抑制原始y標籤並將y2代替。 – alittleboy