I have successfully edited the x and y axis titles, but I'm stuck on the legend title and labels.
Here is the code I have run so far:
m.emo.plot <- interact_plot(model = m.emo, pred = cemodiff, modx = onlychildcg, data = data)
m.emo.plot
m.emo.plot + labs(x ="Emotional Difficulty of Care", y = "Psychological Well-being", legend.title = "Sibling Structure")
which gives me this plot:
I want to edit the legend so that onlychildcg
says "Sibling Structure," the 0
is relabeled as "1+ siblings" and the 1
is relabeled as "Only child."
Here are a few things I have tried but haven't worked:
#m.emo.plot2 <- m.emo.plot + scale_fill_discrete(name = "New Legend Title")
#m.emo.plot$labels$colour <- "New legend title"
#m.emo.plot + labs(x ="Emotional Difficulty of Care", y = "Psychological Well-being", legend.title = "Sibling Structure", color='NEW LEGEND TITLE')
#m.emo.plot + labs(x ="Emotional Difficulty of Care", y = "Psychological Well-being", legend.title = "Sibling Structure", fill='NEW LEGEND TITLE')
#m.emo.plot + guides(fill=guide_legend(title="New Legend Title"))
#adds a new legend but doesn't remove current one and has two solid lines, not one solid and one dashed
#m.emo.plot + labs(x ="Emotional Difficulty of Care", y = "Psychological Well-being", legend.title = "Sibling Structure") + guide_legend(title="my awesome title")
#Can't add `guide_legend(title = "my awesome title")` to a <ggplot> object.
Any advice would be very appreciated!!
interact_plot
come from? That's not a ggplot2 function. It's easier to help you if you include a simple reproducible example with sample input that can be used to test and verify possible solutions.