R中的黑白线条图

R中的黑白线条图,r,R,我想在R中创建一个黑白图,在同一个图上绘制4个不同的变量 绘图非常小,因此我不想使用type=“o”或其他默认类型 相反,我想用简单的细线,虚线,粗线,粗虚线,有什么办法吗?对于黑白打印时使用的最佳符号,您还有其他建议吗?查看plot()和lines()的lty参数查看plot()和lines()的lty参数?par将为您提供有关这方面的几乎所有信息 基本上,您需要的是: lty指定线型 lwd指定线宽 col指定颜色(另请参见rgb) 另请参见Quick-R上的此内容。?par将为您提供有

我想在R中创建一个黑白图,在同一个图上绘制4个不同的变量

绘图非常小,因此我不想使用type=“o”或其他默认类型


相反,我想用简单的细线,虚线,粗线,粗虚线,有什么办法吗?对于黑白打印时使用的最佳符号,您还有其他建议吗?

查看
plot()
lines()的
lty
参数查看
plot()和
lines()的
lty
参数

?par
将为您提供有关这方面的几乎所有信息

基本上,您需要的是:

  • lty
    指定线型
  • lwd
    指定线宽
  • col
    指定颜色(另请参见
    rgb

另请参见Quick-R上的此内容。

?par
将为您提供有关此内容的几乎所有信息

基本上,您需要的是:

  • lty
    指定线型
  • lwd
    指定线宽
  • col
    指定颜色(另请参见
    rgb

请参见Quick-R上的这一点。

是的,当然有可能。您应该使用
lty
code。例如,如果要表示两个变量,应该尝试
lty=c(1,23)
。你可以尝试不同的数字组合。要绘制较粗的线条,
lwd
命令应该会有所帮助。有关更多详细信息,请查看下面的链接


是的,当然有可能。您应该使用
lty
code。例如,如果要表示两个变量,应该尝试
lty=c(1,23)
。你可以尝试不同的数字组合。要绘制较粗的线条,
lwd
命令应该会有所帮助。有关更多详细信息,请查看下面的链接


在R中用多条线绘制黑白线

# Generate some data
x<-1:25; 
y1<-c(0.966,    0.8491, 0.7923, 0.7488, 0.7176, 0.6905, 0.6693, 0.6552, 0.6397, 0.6295, 0.616,  0.6081, 0.6002, 0.5915, 0.5839, 0.5773, 0.5704, 0.563,  0.5563, 0.5508, 0.5435, 0.5405, 0.5328, 0.5281, 0.522); 
y2<-c(0.7925,   0.75,   0.7269, 0.6868, 0.7097, 0.6695, 0.6517, 0.6531, 0.6698, 0.6375, 0.641,  0.6427, 0.6347, 0.633,  0.628,  0.6251, 0.6291, 0.6305, 0.6517, 0.63,   0.6363, 0.6224, 0.6257, 0.6364, 0.6322);
y3<-c(0.8925,   0.85,   0.8269, 0.7868, 0.7097, 0.7695, 0.5517, 0.6531, 0.5698, 0.5375, 0.541,  0.5427, 0.5347, 0.533,  0.528,  0.5251, 0.5291, 0.5305, 0.5517, 0.53,   0.5363, 0.5224, 0.5257, 0.5364, 0.5322);

# Give a name for the chart file
png(file = "line_plot.png", width = 500, height = 300)

# Display the line plot in black and white with multiple lines.
plot(x, y1, type="b", pch=19, col="black", xlab="X-Label", ylab="Y-label", lwd = 1, cex=1)

# Add a line
lines(x, y2, pch=18, col="black", type="b", lty="dashed", lwd = 1)

# Add another line
lines(x, y3, pch=16, col="black", type="b", lty="dotted", lwd = 1)

# Add a legend
legend(19, 0.95, legend=c("Algorithm1", "Algorithm2", "Algorithm3" ), col=c("black", "black", "black"), lty=1:3, cex=1, box.lty=1, box.lwd=1, box.col="black")

# Save the file
dev.off()
#生成一些数据

xR中的黑白线条图,有多条线条

# Generate some data
x<-1:25; 
y1<-c(0.966,    0.8491, 0.7923, 0.7488, 0.7176, 0.6905, 0.6693, 0.6552, 0.6397, 0.6295, 0.616,  0.6081, 0.6002, 0.5915, 0.5839, 0.5773, 0.5704, 0.563,  0.5563, 0.5508, 0.5435, 0.5405, 0.5328, 0.5281, 0.522); 
y2<-c(0.7925,   0.75,   0.7269, 0.6868, 0.7097, 0.6695, 0.6517, 0.6531, 0.6698, 0.6375, 0.641,  0.6427, 0.6347, 0.633,  0.628,  0.6251, 0.6291, 0.6305, 0.6517, 0.63,   0.6363, 0.6224, 0.6257, 0.6364, 0.6322);
y3<-c(0.8925,   0.85,   0.8269, 0.7868, 0.7097, 0.7695, 0.5517, 0.6531, 0.5698, 0.5375, 0.541,  0.5427, 0.5347, 0.533,  0.528,  0.5251, 0.5291, 0.5305, 0.5517, 0.53,   0.5363, 0.5224, 0.5257, 0.5364, 0.5322);

# Give a name for the chart file
png(file = "line_plot.png", width = 500, height = 300)

# Display the line plot in black and white with multiple lines.
plot(x, y1, type="b", pch=19, col="black", xlab="X-Label", ylab="Y-label", lwd = 1, cex=1)

# Add a line
lines(x, y2, pch=18, col="black", type="b", lty="dashed", lwd = 1)

# Add another line
lines(x, y3, pch=16, col="black", type="b", lty="dotted", lwd = 1)

# Add a legend
legend(19, 0.95, legend=c("Algorithm1", "Algorithm2", "Algorithm3" ), col=c("black", "black", "black"), lty=1:3, cex=1, box.lty=1, box.lwd=1, box.col="black")

# Save the file
dev.off()
#生成一些数据
x