Anna1364
Anna1364

Reputation: 154

density curve plot in ggplot

I am new in ggplot and I am trying to draw a density curve. This is a simplified version of the code that I am trying to use:

ggplot(data=ind1, aes(ind1$V1)) + 
geom_density(fill = "red", colour = "black") + xlim(0, 30)

The density curve plot that I get looks like this: enter image description here

I do not understand what is wrong here! does anyone have any idea what is wrong?

Upvotes: 0

Views: 315

Answers (1)

VFreguglia
VFreguglia

Reputation: 2311

Use the adjust parameter.

 ggplot(data=iris, aes(iris$Sepal.Length)) + 
 geom_density(fill = "red", colour = "black",adjust=3) + xlim(0, 30)

Just so you can compare how the parameter affects the smoothing:

 ggplot(data=iris, aes(iris$Sepal.Length)) + 
 geom_density(fill = "red", colour = "black",adjust=1/2) + xlim(0, 30)

Try a couple different values (I think a little greater than 1 will produce the result you want).

Upvotes: 0

Related Questions