Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/75.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R 轴在ggplot2中接触的像素缺失_R_Charts_Ggplot2 - Fatal编程技术网

R 轴在ggplot2中接触的像素缺失

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

我注意到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,
        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