nmi_a <- c(0.8002, 0.8103, 0.8232, 0.8406, 0.8505, 0.8400, 0.8701, 0.8506)
ari_a <- c(0.8003, 0.8133, 0.8242, 0.8206, 0.8105, 0.8100, 0.8601, 0.8306)
pair_a <- c(0, 1000, 2000, 3000, 4000, 5000, 6000, 7000)
acc_b <- c(0.9001, 0.9101, 0.9202, 0.9306, 0.9605, 0.9453, 0.9788, 0.9966)
nmi_b <- c(0.9002, 0.9103, 0.9232, 0.9406, 0.9505, 0.9400, 0.9701, 0.9506)
ari_b <- c(0.9003, 0.9133, 0.9242, 0.9206, 0.9105, 0.9100, 0.9601, 0.9306)
pair_b <- c(0, 1000, 2000, 3000, 4000, 5000, 6000, 7000)
我现有以上两组的数据集,想按照a为实线、b为虚线,大概按照附件下图的折线图,将a、b两组数据以实线、虚线进行区分,画在同一张图中,请问能详细指导下该如何编写代码吗?初接触R语言,感谢大佬讲解!!
我单画一组a的代码如下,请问大佬要如何修改,添加组b并以虚线表示在一张图中呢?
acc <- c(0.8001, 0.8101, 0.8202, 0.8306, 0.8605, 0.8453, 0.8788, 0.8966)
nmi <- c(0.8002, 0.8103, 0.8232, 0.8406, 0.8505, 0.8400, 0.8701, 0.8506)
ari <- c(0.8003, 0.8133, 0.8242, 0.8206, 0.8105, 0.8100, 0.8601, 0.8306)
pair <- c(0, 1000, 2000, 3000, 4000, 5000, 6000, 7000)
library(tidyr)
library(ggplot2)
df <- data.frame(acc, ari, nmi, pair)
df <- df %>% pivot_longer(1:3, names_to = 'type', values_to = 'value')
ggplot(df, aes(x = pair, y = value, colour = type, shape = type)) +
geom_point() + geom_line() + theme_bw() +
theme(legend.title = element_blank(), legend.position = 'bottom') +
xlab('No. of Pairwise Constrains') + ylab('')


雷达卡



京公网安备 11010802022788号







