R 如何在ggplot2中删除/删除条与面板之间的空间?
以下代码生成附加的绘图。如何清除/删除红色标记的区域R 如何在ggplot2中删除/删除条与面板之间的空间?,r,ggplot2,geom-col,R,Ggplot2,Geom Col,以下代码生成附加的绘图。如何清除/删除红色标记的区域 df <- data.frame(trt = c("a", "b", "c"), outcome = c(2.3, 1.9, 3.2)) ggplot(df, aes(trt, outcome)) + geom_col() df边距选项用于打印窗口外部。要在打印窗口中进行更改,请尝试以下操作: ggplot(df, aes(trt, outcome))
df <- data.frame(trt = c("a", "b", "c"), outcome = c(2.3, 1.9, 3.2))
ggplot(df, aes(trt, outcome)) +
geom_col()
df边距选项用于打印窗口外部。要在打印窗口中进行更改,请尝试以下操作:
ggplot(df, aes(trt, outcome)) +
geom_col() +
coord_cartesian(expand = F)
“边距”选项用于打印窗口外部。要在打印窗口中进行更改,请尝试以下操作:
ggplot(df, aes(trt, outcome)) +
geom_col() +
coord_cartesian(expand = F)
您可以在两个轴上将展开设置为0:
library(ggplot2)
df <- data.frame(trt = c("a", "b", "c"), outcome = c(2.3, 1.9, 3.2))
ggplot(df, aes(trt, outcome)) +
geom_col() +
scale_x_discrete(expand = c(0,0)) +
scale_y_continuous(expand = c(0,0))
库(ggplot2)
df您可以在两个轴上将扩展设置为0:
library(ggplot2)
df <- data.frame(trt = c("a", "b", "c"), outcome = c(2.3, 1.9, 3.2))
ggplot(df, aes(trt, outcome)) +
geom_col() +
scale_x_discrete(expand = c(0,0)) +
scale_y_continuous(expand = c(0,0))
库(ggplot2)
df我永远不知道它的expand=c(0,0)或expand=F。它们似乎都起作用?是的,在这种情况下,它们似乎都以相同的方式起作用。我永远不知道它的expand=c(0,0)或expand=F。它们似乎都起作用?是的,在这种情况下,它们似乎都以相同的方式起作用。