When you have flipped coordinates, how do you reduce the space between bars that are narrow and the panel border? Using the data frame df and the ggplot
commands, there is much white space between the bottom bar and the tick marks (and similarly a wide space above the "vendor" bar).
df <- data.frame(x = c("firm", "vendor"), y = c(50, 20))
ggplot(df, aes(x = x, y = y)) +
geom_bar(stat = "identity", width = 0.4) +
theme_tufte() + coord_flip() +
labs(x = "", y = "")
I tried scale_x_discrete
with both limits
and expand
arguments to no avail as well as position = position dodge
, likewise with no effect.
This question offers coord_equal
to change the aspect ratio, and thereby reduce or eliminate the extra space, but notes that the solution does not work with coord_flip
.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…