Rグラフィックシステム:追加したラベルを積み上げ棒グラフ
質問
いなければならないというニーズを追加ラベル、すなわち絶対値を、積み上げ棒グラフの基本的なプロットの機能R.ラベルは内部の積層キャンペーンを行ってきました。
感謝です。
解決
barplot
戻りますのx位置のバーでなにができる
mydata <- matrix(c(10, 21, 22, 33, 45, 23, 22, 43, 33), nrow=3)
# b will contain the x midpoints of the bars
b <- barplot(mydata)
# This will write labels in the middle of the bars, horizontally and vertically
text(b, colMeans(mydata), c("Label1", "Label2", "Label3"))
# This will write labels in the middle of the middle block
text(b, mydata[1,]+mydata[2,]/2, c("LabelA", "LabelB", "LabelC"))
編集: 再読ご質問ありがとう思いかないもんでっD)
# Find the top y position of each block
ypos <- apply(mydata, 2, cumsum)
# Move it downwards half the size of each block
ypos <- ypos - mydata/2
ypos <- t(ypos)
text(b, ypos, mydata)
他のヒント
どのように単純な機能 text()
?
できるだけで追加の文字列はすっきりとしたいので、例えば:
text (x = ..., y = ..., labels = c("foo bar 1000"))
も使用でき、検査の barp 機能の plotrix パッケージ
所属していません StackOverflow