Graph 在下面的代码中,您如何控制geom_线的颜色方案?

Graph 在下面的代码中,您如何控制geom_线的颜色方案?,graph,colors,yaxis,Graph,Colors,Yaxis,我有一个结合了条形图和连接散点图的图表,按时间段分组。我已经使用了scale\u fill\u手动功能来操作条形图的颜色。R为条形图上方的温度线使用默认颜色。我再次尝试使用“缩放填充”手册,但它不起作用,而且在使用该功能时,我似乎无法指定颜色。有什么方法可以改变它们(我希望它们是黄色、橙色和红色,以显示温度随时间的升高)。谢谢 am_-graph让任何想知道的人都能使用它 am_graph <- ggplot((am), aes(x=factor(Month,levels=month.ab

我有一个结合了条形图和连接散点图的图表,按时间段分组。我已经使用了scale\u fill\u手动功能来操作条形图的颜色。R为条形图上方的温度线使用默认颜色。我再次尝试使用“缩放填充”手册,但它不起作用,而且在使用该功能时,我似乎无法指定颜色。有什么方法可以改变它们(我希望它们是黄色、橙色和红色,以显示温度随时间的升高)。谢谢


am_-graph让任何想知道的人都能使用它

am_graph <- ggplot((am), aes(x=factor(Month,levels=month.abb))) +
  geom_col(aes(y = Precipitation, group = Timeframe, fill = Timeframe), width = .7, position = "dodge") +
  geom_line(size = 0.5, aes(y = Mean_Temperature*10, group = Timeframe, col = case_when(
    Timeframe == "1970-2000" ~ "1970-2000",
    Timeframe== 2018 ~ "2018",
    TRUE ~ "2041-2060"))) +
  geom_point(size = 0.5, aes(y = Mean_Temperature*10, group = Timeframe)) +
  ggtitle("Alto Mayo Monthly Climate Conditions (1970-2060)") +
  xlab("Month") +
  ylab("Precipitation (mm)") +
  scale_y_continuous(breaks = seq(0, 220, by = 20), limit = c(0, 220), expand = c(0, 0), sec.axis = sec_axis(~./10, name = "Temperature (°C)")) +
  scale_fill_manual(name = "Precipitation", values = c("lightblue2", "steelblue2", "royalblue1")) +
  scale_color_manual(values = c("lightgoldenrod2", "darkorange2", "tomato3")) +
  guides(col = guide_legend("Temperature")) +
  theme_classic()
am\u图
am_graph <- ggplot((am), aes(x=factor(Month,levels=month.abb))) +
  geom_col(aes(y = Precipitation, group = Timeframe, fill = Timeframe), width = .7, position = "dodge") +
  geom_line(size = 0.5, aes(y = Mean_Temperature*10, group = Timeframe, col = case_when(
    Timeframe == "1970-2000" ~ "1970-2000",
    Timeframe== 2018 ~ "2018",
    TRUE ~ "2041-2060"))) +
  geom_point(size = 0.5, aes(y = Mean_Temperature*10, group = Timeframe)) +
  ggtitle("Alto Mayo Monthly Climate Conditions (1970-2060)") +
  xlab("Month") +
  ylab("Precipitation (mm)") +
  scale_y_continuous(breaks = seq(0, 220, by = 20), limit = c(0, 220), expand = c(0, 0), sec.axis = sec_axis(~./10, name = "Temperature (°C)")) +
  scale_fill_manual(name = "Precipitation", values = c("lightblue2", "steelblue2", "royalblue1")) +
  scale_color_manual(values = c("lightgoldenrod2", "darkorange2", "tomato3")) +
  guides(col = guide_legend("Temperature")) +
  theme_classic()