I am plotting a bar plot with ggplot2. I want the bar width is very small,but the distance between the bars is very large, like the picture, how can I change the distance?
Asked
Active
Viewed 150 times
0
Richard Telford
- 8,978
- 6
- 36
- 50
heihei
- 1
-
3Welcome to stack overflow. Itβs easier to help if you make your question reproducible: include a minimal dataset in the form of an object for example if a data frame as df β Peter Jul 01 '20 at 14:48
-
Does this answer your question? [ggplot2 : How to reduce the width AND the space between bars with geom\_bar](https://stackoverflow.com/questions/50077342/ggplot2-how-to-reduce-the-width-and-the-space-between-bars-with-geom-bar) β tjebo Jul 01 '20 at 16:24
2 Answers
0
Here is an example ggplot(data = df, aes(x=X, y=Y, fill=F)) + geom_bar(width = 0.5, position = position_dodge(width = 0.8))
position_dodge(width = 0.8) is for the space between the bars. width = 0.5 is an example for the withd of the bar itself.
Let me know if it worked :)
Elias
- 666
- 4
- 19
-
No,this is not what i want.what i want is that the X -axis xticks is can be change by set specific number so that the space between bars is very larger or smaller.Thank you . β heihei Jul 02 '20 at 03:49
0
This question has been aswered at ggplot2 : How to reduce the width AND the space between bars with geom_bar
library(tidyverse)
ggplot(data = iris,
mapping = aes(x = Species,
y = Sepal.Length))+
geom_col(width = .5)+
theme(aspect.ratio = 3/2)
Susan Switzer
- 915
- 5
- 26