我正在試用ggplot包R語言。 我的任務是繪製從這個優秀的論文中的圖片顯示的圖表: http://cmup.fc.up.pt/cmup/engmat/2012/seminario/artigos2012/Luis_Ferreira/Using%20logistic%20regression%20to%20estimate%20the%20influence%20of%20accident.pdf如何在y軸上創建比例值的直方圖?
能否請您給我如何繪製一些這方面的暗示? 預先感謝您
我正在試用ggplot包R語言。 我的任務是繪製從這個優秀的論文中的圖片顯示的圖表: http://cmup.fc.up.pt/cmup/engmat/2012/seminario/artigos2012/Luis_Ferreira/Using%20logistic%20regression%20to%20estimate%20the%20influence%20of%20accident.pdf如何在y軸上創建比例值的直方圖?
能否請您給我如何繪製一些這方面的暗示? 預先感謝您
我認爲這是你在找什麼:
# Category names
my.names <- c("test1","test2","test3")
# Example data
data <- runif(length(my.names))
# Normalize the example data as a percentage of the total
data.norm <- data/sum(data)
# Use barplot to plot the results, plot without an x axis
x <- barplot(data.norm,names.arg=my.names,xaxt="n")
# Apply new x labels rotated by 45 degrees
text(cex=1, x=x-0.1, y=-0.05, my.names, xpd=TRUE, srt=45)
這是我做的:
bp<-barplot(data.norm, beside=TRUE, col=c("grey10","grey20","grey30","grey40","grey50","grey60","grey70","grey80","grey90","grey80","grey70","grey60",))text(bp, par("usr")[3], labels=my.names, srt=45, pos=2, xpd=TRUE,offset=0.01)
它的工作的罰款我希望這對其他人有幫助 Regards
可以請你告訴我如何修改代碼以獲得45度旋轉的X軸標籤?問候 – user1997567 2014-09-02 18:25:42
我編輯我的迴應上面,包括旋轉45度的標籤。希望能幫助到你。 – 2014-09-03 22:01:57