R 轴在ggplot2中接触的像素缺失
我注意到ggplot2在x轴和y轴之间留有一个小间隙。 考虑下面的代码:R 轴在ggplot2中接触的像素缺失,r,charts,ggplot2,R,Charts,Ggplot2,我注意到ggplot2在x轴和y轴之间留有一个小间隙。 考虑下面的代码: require(ggplot2, quietly=TRUE) axisLines = element_line(color="black", size = 2) p= ggplot(BOD, aes(x=Time, y=demand)) + geom_line() + theme(axis.line.x = axisLines, axis.line.y = axisLines, pa
require(ggplot2, quietly=TRUE)
axisLines = element_line(color="black", size = 2)
p= ggplot(BOD, aes(x=Time, y=demand)) + geom_line() +
theme(axis.line.x = axisLines,
axis.line.y = axisLines,
panel.background = element_blank())
p
结果显示了图形中丑陋的“缺失角”(用红色圆圈强调)
我还没有看到一个ggplot示例不发生这种情况(但是,很多示例都发生了这种情况,例如)
我试着在轴上添加一条几何线或几何线,但它们不能填补空白,因为它位于图形区域之外
如果有人能解决这个问题,例如手动添加点或稍微移动轴,我将不胜感激。尝试更改
lineend
lineend=“square”
似乎有效
axisLines = element_line(color="black", size = 2, lineend = "square")
p= ggplot(BOD, aes(x=Time, y=demand)) + geom_line() +
theme(axis.line.x = axisLines,
axis.line.y = axisLines,
panel.background = element_blank())
p
有关lineend