Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R - ggplot - jitter plot with transparent data points

Tags:

r

ggplot2

jitter

I want to get a jitter plot with transparent data points and I use this code:

p<-ggplot(house_data,aes(x=cloudCover, y=solar_energy, color = day_night)) 
p<-p+geom_jitter()
p<-p+geom_point(alpha = 0.01)
p

I get a jitter plot but unfortunately I do not get transparent data points. I experimented with different values for alpha but the plot stays the same... What is wrong with my code?

like image 732
Tobitor Avatar asked Aug 12 '26 05:08

Tobitor


1 Answers

You should be able to use position_jitter in the point geometry. The width and height parameters are the amount of jitter on the x- and y-axes respectively:

p<-ggplot(house_data,aes(x=cloudCover, y=solar_energy, color = day_night)) 
p<-p+geom_point(alpha = 0.01, position=position_jitter(height=.5, width=.5))
p
like image 93
DaveArmstrong Avatar answered Aug 14 '26 11:08

DaveArmstrong



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!