我之前问了一个问题。这是链接:how to add a vertical line using theme() function in my plot
现在新问题发生了,band6的水平线无法完全显示。有人可以给我一些建议吗?谢谢。
我的代码如下:
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(expand = c(0,0),breaks = c(5,10,15,20,25,30,35,40,45)) +
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())
答案 0 :(得分:1)
好的,发帖回答:
不要在data$column
内使用aes()
。如果您尝试使用其他高级功能,则会导致问题。你应该
aes(x = MeanDecreaseAccuracy,
y = reorder(factor(Variables, MeanDecreaseAccuracy)))
要解决您的问题,我建议您设置limits = c(0, 1.05 * max(df1$MeanDecreaseAccuracy))
。在scale_x_continuous
内。 (请注意,aes()
内的不是,因此您需要在此处使用data$column
标识符。