白色空格虚线图R.

时间:2016-07-15 06:27:39

标签: r plot

我想在绘图中绘制多行。因此,我正在使用lty= 2,3等等。但在图中,虚线之间几乎没有白色香料。有没有办法增加虚线之间的空白?因为现在几乎没有区别。

2 个答案:

答案 0 :(得分:3)

许多绘图函数的lty参数接受长度为2,4,6和8的字符串,然后指定" on"和"关"长度对应每个字符。

比较以下几行,并使用参数来获取想法:

plot(c(1,2),  c(1.0,1.0), type = "l", lty = "29", col = "red")
lines(c(1,2), c(1.2,1.2), type = "l", lty = "99", col = "orange")
lines(c(1,2), c(0.8,0.8), type = "l", lty = "2947", col = "blue")

编辑:详细说明。第一个字符定义第一行破折号的长度。第二个字符定义了行 break 的长度。第三个和第四个字符分别定义下一行破折号和破碎的长度,依此类推。然后重复生成的虚线图案。 尝试例如与lty = "12345678"一起看 - 这应该是越来越大的破折号和破折号。

答案 1 :(得分:0)

如果您正在使用基础绘图库。您可以尝试更改参数 lwd

借用本教程中的一些代码 http://www.cookbook-r.com/Graphs/Shapes_and_line_types/

set.seed(331)

# Plot some points with lines
# Set up the plotting area
par(mar=c(3,3,2,2))
plot(NA, xlim=c(1,4), ylim=c(0,1))

# Plot solid circles with solid lines
points(1:4, runif(4), type="b", pch=19,lty=4, lwd=2)

# Add open squares with dashed line, with heavier line width
points(1:4, runif(4), type="b", pch=0,  lty=4, lwd=4)

points(1:4, runif(4), type="b", pch=23,   # Diamond shape
       lty=4, cex=2,  lwd=8,             # Dotted line, double-size shapes,  fattest line
       col="#000099", bg="#FF6666")       # blue line, red fill

Click here查看此图表输出的示例