Sameh Magdeldin
Sameh Magdeldin

Reputation: 473

Why setting transparency (alpha) for background is not working in ggplot?

I'm facing some difficulties to set my background plot with some transparency. simply, whenever I set alpha to any value, same opaque background is returned. Although there is some posts regarding background highlighting such as

customize background to highlight ranges of data in ggplot

How to highlight time ranges on a plot?

ggplot2: highlight chart area

But unfortunately, this issue is not discussed here or there. I would appreciate your comments

Here is some data for demo

install.packages("ggplot2")

First , using geom_rect

ggplot(mtcars, aes(x=wt, y=qsec)) + 
geom_point(color="black",size=8) + 
theme_bw() +
geom_rect(aes(xmin=4,xmax=5,ymin=14,ymax=Inf),alpha=0.9,fill="green")

Playing with alpha wont help and ultimately, that is what I got

data from mtcars

Using annotate function , I can not generate it also.

Upvotes: 0

Views: 2138

Answers (1)

user3710546
user3710546

Reputation:

Your value for alpha is too high.

enter image description here

Upvotes: 1

Related Questions