0

My x-axis is formated as Dates using the Lubridate package.

I have tried different options with the xlim and breaks but can't seem to get "2020" to fit within the figure.

interest_exp_line <- ggplot(interest_exp_df, aes(x = year,
                                                 y = value,
                                                 colour = country_name,
                                                 group = country_name)
                            )

interest_exp_line2 <- interest_exp_line +
  geom_line() +
  geom_hline(yintercept = 0)

interest_exp_line3 <- interest_exp_line2 +
  bbc_style() +
  scale_x_date(date_labels = "%Y") +
    theme(axis.title.x = element_text(size = 12), 
        axis.title.y = element_text(size = 12)
        ) +
  labs(title = "Is Ghana the next Zambia?",
       subtitle = "Ghana isn't getting any better...", 
       x = "Year",
       y = "Interest payments\n(% of expenses)")


finalise_plot(plot_name = interest_exp_line3,
              source = "Source: World Bank",
              save_filepath = "c:/workspace/repos/world_bank_data/outputs/figures/ghana_zambia_interest_line.png",
              width_pixels = 640,
              height_pixels = 450
              )

My plot looks like this:

enter image description here

Bandit King
  • 183
  • 10
  • To help us to help you could you please make your issue reproducible by sharing a sample of your **data**? See [how to make a minimal reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). Simply type `dput(NAME_OF_DATASET)` into the console and copy & paste the output starting with `structure(....` into your post. – stefan Jul 20 '21 at 22:21

1 Answers1

0

I just figured it out now...

It had nothing to do with scales and needed a theme adjustment. I corrected it by altering the theme using plot.margin = margin(10, 15, 10, 10)

Bandit King
  • 183
  • 10