从绘图中删除线 [英] Deleting Line from Plot

查看:163
本文介绍了从绘图中删除线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只是一个简单的问题:我试图在R中绘制一个图表,并且已经介绍了如何做到这一点,但是如何删除刚创建的一行?例如:

  x < -  c(1,2,4,5,6.7,7,8,10)$ (40,30,10,20,53,20,10,5)

plot(x,y,main =X vs Y,xlab =X ,ylab =Y)

lines(x,y,col =black,lty =dotted)

这产生了一个很好的图形。但是,如果我想删除之前创建的行(或者也可能是要点?!),我应该怎么做呢?

解决方案

在R基础上删除的技巧是重新绘制除了要在新图中删除的内容以外的所有内容



所以如果你:

  plot(x,y,main =X vs Y,xlab =X,ylab =Y)
lines(x,y,col =black,lty =dotted)
pre>

然后决定你不要这条线然后你:

  plot(x,y,main =X vs Y,xlab =X,ylab =Y)

然后,如果你想擦除everthing,那么你可以使用

  plot.new()
code>


Just a quick question: I'm trying to plot a graph in R and I have covered how to do that, but how do I delete a line I have just created? For instance:

x <- c(1, 2, 4, 5, 6.7, 7, 8, 10 )
y <- c(40, 30, 10, 20, 53, 20, 10, 5)

plot(x,y,main="X vs Y", xlab="X", ylab="Y")

lines(x,y,col="black",lty="dotted") 

This produces a nice graph. However, say I would like to delete the line I created previously (or perhaps the points as well?!) how should I go about doing it?

解决方案

The trick to erasing in R base is to redraw everything except what you want to erase in a new plot

so if you:

plot(x,y,main="X vs Y", xlab="X", ylab="Y")
lines(x,y,col="black",lty="dotted") 

then decide that you dont want the line then you:

plot(x,y,main="X vs Y", xlab="X", ylab="Y")

Then if you want to erase everthing then you

plot.new()

这篇关于从绘图中删除线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆