How to increase size of ggplot - squeezed horizontal bar chart

I'm trying to plot some values against US states in a horizontal bar chart in GGPlot.

The code is:

g <- df %>% 
  select(Sample.Measurement, State.Name) %>% 
  group_by(State.Name) %>% 
  count() %>% 
  arrange(n) %>% 
  ggplot(., mapping = aes(x=reorder(State.Name, n), y =n))+
  geom_bar(stat = "identity", width=.8, position = position_dodge(width = .25))+
  labs(
    title = "",
    y= "Frequency"
  )+
  coord_flip()

g+theme(axis.text=element_text(size=20),
        axis.title=element_text(size=30,face="bold"))

The theming element was in a bid to change the text size.

What I really want to do is extend the depth of the chart so that the individual states have more space. How do I do that?

GGplot chart

1 answer

  • answered 2018-01-11 20:30 Roman Lu┼ítrik

    Edit the chunk options, namely fig.height and fig.width.

    e.g.

    ```{r fig.height = 10, fig.width = 5}
    #your plot code
    ```