摆脱y = 0时R密度图密度中的灰线 [英] Get rid of gray line in R density plot density at y = 0
问题描述
我有一个要保存在eps文件中的密度图。
I have a density plot that I want to save in an eps file.
我的密度图有点像
setEPS()
postscript("myfile.eps")
plot(density(rnorm(1000)))
dev.off()
仅包含我的数据,但稍微复杂一点(更改标签和页边距,在顶部放更多行
just with my data and a little bit more complex (changing labels and margins, more lines on top of it, etc).
我的问题是我在y = 0的密度图上方有一条烦人的水平细灰色线,我想
My problem is that I get an annoying, horizontal thin gray line on top of my density plot at y = 0, and I'd like to get rid of it.
直接绘制到X设备上时,我没有得到水平灰线,但在附言中,我总是这样做。
When plotting directly to the X device I don't get this horizontal gray line, but in postscript I always do.
我尝试使用 dev.copy2eps
和 cairo_ps()
postscript()
,但我仍然能看到灰线。
I've tried using dev.copy2eps
and also cairo_ps()
instead of postscript()
, but I still get the grey line.
我还尝试了使用不同的(和随机数据),其绘制非常简单,例如上面的代码块,并且仍然在后记中显示灰线。
I've also tried using different (and random) data, with a very simple plot like the code block above, and still get the grey line in the postscript.
您知道如何摆脱这一行吗?
Does anyone know how to get rid of this line?
推荐答案
阅读帮助页面:
?plot.density
zero.line .......逻辑;如果为TRUE,则在y = 0处添加一条基线。
zero.line.......logical; if TRUE, add a base line at y = 0
我将承认我没有通过阅读帮助页面来发现这一点。我查看了 density.default
的代码,发现没有任何用处,然后尝试了 plot.density
,却什么也没得到,找到消息,然后尝试:
I will admit that I didn't discover this by reading the help page. I had looked at the code for density.default
, found nothing useful, then tried plot.density
, got the nothing, found message, and then tried:
> getAnywhere(plot.density)
产生了这个...让我意识到 I 应该从帮助页面开始:
Which produced this ... making me realize that I should have started with the help page:
A single object matching ‘plot.density’ was found
It was found in the following places
registered S3 method for plot from namespace stats
namespace:stats
with value
function (x, main = NULL, xlab = NULL, ylab = "Density", type = "l",
zero.line = TRUE, ...)
这篇关于摆脱y = 0时R密度图密度中的灰线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!