Plot points outside plotting region in R

时光怂恿深爱的人放手 提交于 2021-02-08 03:35:09

问题


I want to add points(asterisks) outside the plotting region of a plot in R. However, the following code only allows points to be added inside the plotting region:

x = c(1:10)
y = c(1:10)
plot(x,y)
points(11, 7, pch = 8)

How can I adjust code to allow the point to be plotted outside the plotting region?


回答1:


This SO post might help! It's about legends, but you can probably apply the same method for what you want.

This worked for me:

> par(xpd=TRUE)
> x = c(1:10)
> y = c(1:10)
> plot(x,y)
> points(11, 7, pch = 8)



回答2:


One way:

plot(1:10, 1:10)
par(new = TRUE, mar = c(0,0,0,0))
plot(1:10, 1:10, xaxt = 'n',yaxt='n')


来源:https://stackoverflow.com/questions/11417269/plot-points-outside-plotting-region-in-r

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