ggplot2 主题 axis.line。轴不在原点连接
ggplot2 theme axis.line. axes do not connect at origin
尝试在 ggplot2
中的 theme()
中使用 axis.line
添加自定义轴时,轴不会 "perfectly" 在原点连接。我使用 size=3
来更好地查看此效果。有办法解决这个问题吗?
library(ggplot2)
ggplot(mpg, aes(displ, hwy, colour = class)) +
geom_point()+
theme(axis.line = element_line(color = "black", size=3))
element_line
函数的documentation列出了一些参数。特别感兴趣的是参数 lineend=
。默认值为 "butt"
。如果将其设置为 "square"
,它可以解决问题:
ggplot(mpg, aes(displ, hwy, colour = class)) +
geom_point()+
theme(axis.line = element_line(color = "black", size=3, lineend = 'square'))
尝试在 ggplot2
中的 theme()
中使用 axis.line
添加自定义轴时,轴不会 "perfectly" 在原点连接。我使用 size=3
来更好地查看此效果。有办法解决这个问题吗?
library(ggplot2)
ggplot(mpg, aes(displ, hwy, colour = class)) +
geom_point()+
theme(axis.line = element_line(color = "black", size=3))
element_line
函数的documentation列出了一些参数。特别感兴趣的是参数 lineend=
。默认值为 "butt"
。如果将其设置为 "square"
,它可以解决问题:
ggplot(mpg, aes(displ, hwy, colour = class)) +
geom_point()+
theme(axis.line = element_line(color = "black", size=3, lineend = 'square'))