How to draw a line or add a text outside of the plot area in R?

三世轮回 提交于 2019-12-03 05:01:12

问题


Thank you for reading. I find that I am unable to draw lines/points or add text outside of the plot area. If I draw a line from inside the plot (within the axis) area to the area of the xlab main title areas only the part within the plot shows. In a multiple plot graph (mfrow) the line/point will only be drawn inside the last active plot.

plot(0);
l=locator(2,type='n');
lines(l, type='l'); 

Any solution to this problem? Thanks!


回答1:


The xpd parameter controls where you can draw. Check the current value with par()$xpd and then try setting par(xpd=NA).

From the par help:

 ‘xpd’ A logical value or ‘NA’.  If ‘FALSE’, all plotting is
      clipped to the plot region, if ‘TRUE’, all plotting is
      clipped to the figure region, and if ‘NA’, all plotting is
      clipped to the device region. See also ‘clip’.


来源:https://stackoverflow.com/questions/12496684/how-to-draw-a-line-or-add-a-text-outside-of-the-plot-area-in-r

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!