如何向 R 中的现有绘图添加线条?
How to add lines to existing plot in R?
这是我之前的问题。
我如何向每个终端都有菱形的现有地块(带多边形)添加线(而不是线段)。
您可以为此使用 lines
:
#random plot
plot(1:10, xlim=c(0, 10), ylim=c(0,10))
#then plot line with x1,x2 and y1,y2 co-ordinates
#below x1=0 x2=5 y1=2 and y2=8
lines(c(0, 5), c(2, 8), type='l')
确保在 plot
中添加 xlim
和 ylim
以便 lines
选择正确的比例。
这是我之前的问题。
我如何向每个终端都有菱形的现有地块(带多边形)添加线(而不是线段)。
您可以为此使用 lines
:
#random plot
plot(1:10, xlim=c(0, 10), ylim=c(0,10))
#then plot line with x1,x2 and y1,y2 co-ordinates
#below x1=0 x2=5 y1=2 and y2=8
lines(c(0, 5), c(2, 8), type='l')
确保在 plot
中添加 xlim
和 ylim
以便 lines
选择正确的比例。