Skip to content

I'm confusing about width(height) argument in geom_jitter() #1775

Closed
@kimchpekr

Description

@kimchpekr

"width(height)" argument in geom_jitter() is described as belows.

width

Amount of vertical and horizontal jitter. The jitter is added in both positive and negative directions, so the total spread is twice the value specified here. If omitted, defaults to 40% of the resolution of the data: this means the jitter values will occupy 80% of the implied bins.

So, I expected geom_jitter() and geom_jitter(width = 0.4) will produce same plot and "width = 0.4" spreads points across a range "base ± resolution * 0.4". but the results are not.

> p <- ggplot(mtcars, aes(gear, mpg))
> p + geom_jitter()  ## jitter range is 3 ± 0.4

default

> p + geom_jitter(width = 0.4) ## jitter range is narrow than 3 ± 0.4

width 0 4

I'm confusing about width argument and how can i calculate a jitter range.

I expect like belows but the result doesn't

geom_jitter(width = 0.2) will spread points across a range [2.8 ~ 3.2] : 3 ± 0.2
geom_jitter(width = 0.4) will spread points across a range [2.6 ~ 3.4] : 3 ± 0.4
geom_jitter(width = 0.6) will spread points across a range [2.4 ~ 3.6] : 3 ± 0.6

but, geom_point(aes(x = jitter(gear, amount = 0.2)) produce a plot what i expected.
geom_point jitter

Please, give me some hints...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions