R Paint Package Ggplot2 Introduction

Source: Internet
Author: User

First, Introduction:

Ggplot2 is a very popular drawing package in the R language and is very friendly to use. The realization of Ggplot2 is due to the Leland Wilkinson in his book "TheGrammar of the graphics" proposed a set of graphic grammar, the graphic elements into the composition can be freely combined, Hadley Wickham This set of ideas in R . Hadley Wickham has this special Ggplot2 book------ggplot2: Data analysis and Graphic arts, interested can be read.

Here is an introductory ppt------30 minutes to learn ggplot2.pdf, everyone can view;

Ii. Preparatory work:

1) Install r Software (required):http://www.r-project.org, first select the image, then download;

2) Install Rstudio (optional):Http://www.rstudio.com/products/rstudio/,RStudio is a wide application of the IDE, powerful and friendly, recommended installation;

3) Load Ggplot2 (required): Open R, enter on the command line: Install.packages ("Ggplot2"), will let you choose to automatically install after mirroring, in the script to call the package, you need to load the package, enter the library (GGPLOT2) can be;

Three, Ggplot2 basic concept:

1) Mapping:

The variables in the data are mapped to the graphic properties, such as the following data (table I), the TRT column is mapped to a color (table II), the display effect is shown;

The command is:

data = Data.frame (Length=c (2,1,4,5), Width=c (3,2,5,6), Trt=c ('a','a ','b','b'= ggplot (data, AES (length , width, col=+ geom_point ()

Table I:

Length Width Trt
2 3 A
1 2 A
4 5 B
5 6 B

Table II:

length width Colour
2 3 A
1 2 A
4 5 B
5 6 B

 

Figure One:
Figure One:

2) Scaling (scale):

The scale is responsible for the mapping after the graphical display, specifically the legend and the coordinate scale, that is, the corresponding specific values after mapping, such as table two data, the actual corresponding scale such as:

length width Colour
25 20 Red
0 0 Red
75 60 Blue
100 80 Blue

R Paint Package Ggplot2 Introduction

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.