如何使用plot
將這個繪圖橫向調整,使得直方圖條是水平的?R plot:如何使用plot繪製水平線的直方圖()
size<- abs(rnorm(20,10,10))
age<-c(seq(1, 20, by=2))
plot(size~age, type=("n")); lines(size~age, type=c("l"), lines(size~age, type=c("h")))
我要的是大致這樣的事情,與直方圖線的水平:
我與
plot(size~age, type=("n"), yaxt="n", xaxt="n", ylab=""); lines(size~age, type=c("l"), lines(size~age, type=c("h"))); axis(4); axis(1,las=2)
,然後旋轉做在其他軟件中輸出圖像。
我想知道我怎麼可以使用plot
函數來獲取輸出情節橫盤,所以我可以讓他們的小組在R
不必的R
外旋轉它們。
UPDATE感謝來自@csgillespie非常有幫助的建議,我已經得到了這一點,這也讓我對我的方式:
size<- abs(rnorm(20,10,10))
age<-c(seq(1, 40, by=2)) # sorry for the typo in the first set of example data above
plot(-age~size, type="n",yaxt="n", ylab="Age", xlab="Size")
lines(-age~size)
segments(0, -age, size, -age)
axis(2, labels=c(seq(0,max(age), by=5)), at=-c(seq(0,max(age), by=5)), las=1) # this is a more general approach to labelling the axis ticks
,這裏是導致情節(不漂亮,但我想我從這裏可以做其他):
手動添加它進一步說明您可能會發現在這裏:http://stackoverflow.com/questions/ 3792803/is-it-it-to-rotate-a-plot-in-r-base-graphics – Seb 2012-01-05 10:26:02