R Language Basics Memo plot ()

Source: Internet
Author: User

Plot is the basic drawing tool in R, direct plot (x), x is a data set, you can draw a graph, soeasy! But the details are often the key to winning. So let's take a look at all the programmable parameters and parameter setting methods for plot in detail.

The graphic parameters described below are common parameters in the graphic package and are identical in graphic different graphics methods.

Types of type Graphics

"P" point graph

"L" line chart

"B" point line graph, line does not cross point

"C" dashed chart

"O" point line graph, line crossing point

"H" histogram

"S" Ladder diagram

"S" Step diagram

"N" no diagram

PNG ("~/plotsamples.png", width=9,height=9,unit= "in", res=108)

Par (Mfcol=c (3,3))

Plot (x,type= "P", main= "P")

Plot (x,type= "L", main= "L")

Plot (x,type= "B", main= "B")

Plot (x,type= "C", main= "C")

Plot (x,type= "O", main= "O")

Plot (x,type= "H", main= "H")

Plot (x,type= "s", main= "s")

Plot (x,type= "s", main= "s")

Plot (x,type= "n", main= "n")

Dev.off ()

COL Specifies graphic color

The colors () method allows you to view all of the available color names in R, a total of 657 color names, which can be used to directly set the display color of the graphic according to the color name. The following is a partial color, complete graph link

Http://wenku.baidu.com/link?url=PnCsIjv3e_OGw2COt4AEo3_ Thtisoyohlgf9bf-jjzkfgijhfzpeqrs6caeluypnr82wdj6vclurzzacwbuoszzvhopnnt27rim-uv1b4z3.

In addition to the name, you can use subscript, hexadecimal color value, RGB value, and HSV value to specify the color. Examples: col=1, col= "white", col= "#FFFFFF", Col=rgb (1,1,1) and COL=HSV (0,0,1).

In addition, there are many functions for generating color variables in R. There are Rainbow (), Heat.colors (), Terrain.colors (), Topo.colors (), and Cm.colors () methods, and the gray () method generates a multi-order grayscale color.

Other color-related parameters

PCH Specifies graphics (at type= "P"/"O"/"B")

Lty specifying the line shape

LWD changing the thickness of a line

The par function can be used to set graphical parameters

See the description of type for an example. The following function can see all the parameters that can be set with the par function and their default values.

Print_pars <-function () {

For (Nin names (Par ())) {

P<-par (n)

if (length (p) = = 1) {

Print (paste (n,p,sep= "="))

}else{

Print (Paste (n, "=c (", Paste (p,collapse= ","), sep= "", ")"))

}

}

}

Print_pars ()

Names (Par ()) #只查看可设置参数名

A lot of parameters, the basic is used before, these parameters plot can be directly set when plotting.

Reference books: R language and R Language Core Technical Handbook


R Language Basics Memo plot ()

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.