如何将我的 x 轴日期标签放入图中?

问题描述

我的 x 轴使用 Lubridate 包格式化为日期。

我已尝试使用 xlim 和breaks 的不同选项,但似乎无法将“2020”放入图中。

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
              )

我的情节是这样的:

enter image description here

解决方法

我现在才知道...

它与音阶无关,需要进行主题调整。我通过使用 plot.margin = margin(10,15,10,10)

更改主题来纠正它

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...