Align text inside a plot

前端 未结 2 649
南笙
南笙 2020-12-08 19:46

I am an R newbie and had a question. I am trying to place some text into an R plot. Here\'s some code using the brightness dataset in the UsingR package.

            


        
2条回答
  •  长情又很酷
    2020-12-08 20:43

    Try using legend() instead of text()

    legend(3.5, 150, legend = c(paste("Mean =", round(MyMean, 1)),
                                paste("Median =",round(MyMedian, 1)),
                                paste("Std.Dev =", round(MySd, 1))), 
                      bty = "n")
    

    You'll have to play around with the position adjustment. You might consider not using xy coordinates at all, but replacing those two arguments with "topleft"

提交回复
热议问题