大家, 我想生成如下图。我可以靠近,但不能将垂直线作为y轴添加到零点。 enter image description here
这是我的数据和我的代码:
Variables MeanDecreaseAccuaracy MeanDecreaseGini
band1 33.991 142.946
band2 32.729 165.892
band3 32.254 169.372
band4 36.721 209.631
band5 36.525 141.047
band6 40.496 232.536
band7 39.886 226.782
band8 4.315 5.334
我的代码:
p <- ggplot(data = df1, aes(x = df1$MeanDecreaseAccuaracy, y = reorder(factor(df1$Variables),df1$MeanDecreaseAccuaracy)))
p + geom_segment(aes(yend = df1$Variables,xend = 0)) +
geom_point() +
theme_minimal() +
scale_x_continuous(breaks = c(0,10,20,30,40,50)) +
labs(x = "Mean Decrease in Accuracy",y = "Prdictors variable") +
theme(axis.line = element_line(colour = "black"),
axis.text.x = element_text(colour = "black"),
axis.text.y = element_text(colour = "black"),
axis.ticks.x = element_line(size = 0.2,colour = "black"),
axis.ticks.y = element_line(size = 0.2,colour = "black"),
panel.grid.major = element_blank(),
panel.grid.minor = element_blank())
注意:df1是我的数据。 这是我的情节。 enter image description here