0

I am trying to do a plot with a regression line and cannot remove the confidence interval color from the fill caption.

  ggplot(KF, aes(x = d18O, y = d66Zn)) +
    facet_grid(. ~ Tissue) +
    geom_smooth(
      method = lm, aes(fill = "Confidence Interval"), 
      colour = "black",
      se = FALSE
    ) +
    geom_point(aes(fill = Diet, shape = Water_dependence), size = 4, color = "white") +
    scale_shape_manual(values = c(21:25)) +
    scale_fill_manual(values = palettedietb)+          
    labs(
      x = expression(paste(delta^18, "O (‰)")),
      y = expression(paste(delta^66, "Zn (‰) ")),
      fill = "Diet", shape = "Water dependence"
    ) +
    theme(
      strip.background = element_rect(fill = "white", color = "black", size = 16),
      strip.text = element_text(size = 16, color = "white"),
      panel.background = element_rect(fill = "white", color = "black"),
      legend.title = element_text(size = 16),
      axis.title.x = element_text(size = 16),
      axis.title.y = element_text(size = 16),
      legend.text = element_text(size = 12),
      axis.text.x = element_text(size = 12),
      axis.text.y = element_text(size = 12)
    ) +
    guides(
      fill = guide_legend(override.aes = list(shape = 21, color = "white")),
      shape = guide_legend(override.aes = list(fill = "black", color = "black"))
    )

i closed r studio and reopened it to only load ggplot2 i tried to use breaks i tried to use show.legend=FALSE nothing works

stefan
  • 90,330
  • 6
  • 25
  • 51
MGall
  • 1
  • Welcome to SO! It would be easier to help you if you provide [a minimal reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) including a snippet of your data or some fake data. Also, to me it's not 100% clear what you mean by *remove the confidence interval color from the fill caption*. If that means that you want to remove `Confidence Interval` as showing up in the legend you could probably do so by dropping `aes(fill = "Confidence Interval")` from `geom_smooth`. – stefan Aug 04 '23 at 05:50

0 Answers0