I'd like to change the background color for my annotate text so that it's green and covers up anything behind it (like the horizontal line in the example below). How do I do that?
ggplot() +
geom_hline(yintercept=0) +
annotate("text",x=0,y=0,label="Here is a line")
Checking Color Contrast. Changing the color and background color of text is also essential for avoiding problems of web accessibility on your website.
Highlighting Text The best color combinations for highlighting information are as follows: Red (#FF0000) text on a white (#FFFFFF) background. Purple (#990099) text on a white (#FFFFFF) background. Yellow (#FFFF00) text on a Prussian blue (#003366) background.
Try geom_label
instead:
ggplot() +
geom_hline(yintercept = 0) +
labs(x = "", y = "") +
geom_label(aes(x = 0, y = 0, label = "Here is a line"), fill = "green")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With