Graphics Reference
In-Depth Information
For narrower bars:
ggplot(pg_mean, aes(x = group, y = weight)) + geom_bar(stat = "identity" , width = 0.5 )
And for wider bars (these have the maximum width of 1):
ggplot(pg_mean, aes(x = group, y = weight)) + geom_bar(stat = "identity" , width = 1 )
Figure 3-13. Different bar widths
For grouped bars, the default is to have no space between bars within each group. To add space
between bars within a group, make width smaller and set the value for position_dodge to be
larger than width ( Figure 3-14 ).
For a grouped bar graph with narrow bars:
ggplot(cabbage_exp, aes(x = Date, y = Weight, fill = Cultivar)) +
geom_bar(stat = "identity" , width = 0.5 , position = "dodge" )
And with some space between the bars:
ggplot(cabbage_exp, aes(x = Date, y = Weight, fill = Cultivar)) +
geom_bar(stat = "identity" , width = 0.5 , position = position_dodge( 0.7 ))
Search WWH ::




Custom Search