I have this code as given below
ggplot(df1, aes(x = -Ord, y = Value, fill = Item)) +
geom_bar(stat = "identity") +
scale_y_continuous(labels = comma) +
facet_wrap(~Area, scales = "free", drop = T, nrow = 2) +
labs(title = "Major Crops of South Asia, Top 10 on avg of 2006-2015",
caption = "Source: fao.org") +
theme(legend.position = "none",
axis.title.y = element_blank(),
axis.title.x = element_blank(),
axis.text.x = element_blank(),
axis.ticks.x = element_blank(),
plot.caption = element_text(face = "italic")) +
geom_text(aes(label=Item), angle = 65,
vjust=.3, hjust = -.1, size=3)
The image it produces is given as below
as you can see the bar labels are getting cropped. The problem with free scales in facet_wrap is that I cannot use
limits
in scale_y_continuous
otherwise some plot areas would be blank due to wide variation in value range for each country.
So, my query is how to manage adding some extra space by increasing y scale for each plot freely without compromising the scales
.
I have tried scale_y_continuous(limits = c(0, max(df1$Value)), labels = comma)
but then it kills scales = "free"
in facet_wrap
.
And, also the max
values are to be groupwise in order to be really effective. This part I am unable to sort out.
I have deliberately avoided dput data just in case if it is needed kindly let me know. I would supply it. Thanks.