用R语言和这个数据绘制折线图,不用ggplot2
时间: 2024-12-22 11:26:15 浏览: 2
好的,以下是使用R语言绘制折线图的代码示例,不使用`ggplot2`:
```r
# 创建数据框
data <- data.frame(
Soil = c("Common Soil", "Sand Loam and Leaf Mold (3:1)"),
Root_System_Vitality = c(0, 35),
Plant_Height_Increase = c(0, 12)
)
# 绘制根系活力增加百分比的折线图
plot(data$Soil, data$Root_System_Vitality, type = "o", pch = 19, lwd = 2,
xlab = "Soil Type", ylab = "Percentage Increase in Root System Vitality",
main = "Effect of Soil Type on Plant Growth")
# 添加植物高度增加的折线图
lines(data$Soil, data$Plant_Height_Increase, type = "o", pch = 24, lty = 2, lwd = 2, col = "red")
# 添加图例
legend("topright", legend = c("Root System Vitality", "Plant Height Increase"),
col = c("black", "red"), lty = c(1, 2), pch = c(19, 24), lwd = 2)
# 显示图表
```
这段代码会生成一个包含两种土壤类型的折线图,分别显示根系活力增加的百分比和植物高度增加的情况。希望这对你有帮助!
阅读全文