Ggplot2 Geom Related Settings-jitter

Source: Internet
Author: User

Scatter in the R in the time will often appear, point coincident more serious phenomenon, which we are looking for data law or observation data has a great disturbance.

Fortunately, in R, you can use the Geom_jitter () function to adjust and eliminate the overlap of points.

Geom_jitter (mapping = NULL, data = NULL, stat = "identity", Position = "jitter", ..., width = null, height = null, NA.RM = FALSE, show.legend = NA, Inherit.aes = TRUE)

As far as parameters are concerned, geom_jitter () and other functions are not very different, the special two parameters are Width,height

Width used to adjust the widths of point fluctuations

Height is used to adjust the altitude of the point fluctuation

Let's look at a concrete example.

Library (Ggplot2) P<-ggplot (Economics,aes (Pce,pop)) P+geom_point ()  

  

It can be seen that the pop and PCE two data has a good correlation, but it is not possible to see how the concentration of each data location data.

At this point we can use the geom_jitter () to scatter the dots so that we may observe

P+geom_jitter (width=2000,height=20000)

  

It is obvious that points at lower positions are denser than points at higher locations.

If you add a color attribute, the geom_jitter effect becomes more pronounced.

Ggplot2 Geom Related Settings-jitter

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.