Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-cloud-platform/3.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
如何调整ggplot中的panel.borders?_R_Ggplot2 - Fatal编程技术网

如何调整ggplot中的panel.borders?

如何调整ggplot中的panel.borders?,r,ggplot2,R,Ggplot2,我画了一个简单的条形图: mtcars$cnames = rownames(mtcars) ggplot(mtcars[1:5,], aes(cnames, disp)) + geom_bar(stat = "identity") + theme_minimal() + theme(axis.text.x = element_text(angle = 45, hjust = 0.5), panel.border = element_rect(colour = "bl

我画了一个简单的条形图:

mtcars$cnames = rownames(mtcars)
ggplot(mtcars[1:5,], aes(cnames, disp)) + 
  geom_bar(stat = "identity") +
  theme_minimal() +
  theme(axis.text.x = element_text(angle = 45, hjust = 0.5),
        panel.border = element_rect(colour = "black", fill=NA, size=5))
正如您通过运行此示例所看到的,边框将穿过axis.text。
如何降低边界?

希望这就是您想要的:

  mtcars$cnames = rownames(mtcars)
ggplot(mtcars[1:5,], aes(cnames, disp)) + 
    geom_bar(stat = "identity") +
    theme_minimal() +
    theme(axis.text.x = element_text(angle = 45, hjust = 0.5),
          plot.background = element_rect(colour = "black", fill=NA, size=5))

我通过
plot.background