1. 程式人生 > >R語言畫圖函式

R語言畫圖函式

  • par()函式

par can be used to set or query graphical parameters. 

x(y)axs

x(y)axs:The style of axis interval calculation to be used for the x(y)-axis. Possible values are "r", "i", "e", "s", "d". The styles are generally controlled by the range of data or x(y)lim, if given.

Style "r" (regular) first extends the data range by 4 percent at each end and then finds an axis with pretty labels that fits within the extended range.

Style "i" (internal) just finds an axis with pretty labels that fits within the original data range.

Style "s" (standard) finds an axis with pretty labels within which the original data range fits.

Style "e" (extended) is like style "s", except that it is also ensures that there is room for plotting symbols within the bounding box.

Style "d" (direct) specifies that the current axis should be used on subsequent plots.

(Only "r" and "i" styles have been implemented in R.)

x(y)asp

A vector of the form c(x1, x2, n) giving the coordinates of the extreme tick marks and the number of intervals between tick-marks when par("x(y)log") is false.

col

A specification for the default plotting color. See section ‘Color Specification’

使用顏色名:col = "顏色名"

使用數值表達顏色:col = n,n為當前調色盤上的顏色,

使用十六進位制表達顏色 col ="red, green, blue, alpha"

使用col = heat.colors(n)

使用顏色向量col = c()

  • colors()函式

Returns the built-in color names which R knows about.

  • palette()函式

View or manipulate the color palette which is used when a col= has a numeric index

  • heat.colors()函式

Create a vector of n contiguous colors.

the number of colors (≥ 1) to be in the palette

  • rainbow()函式

Create a vector of n contiguous colors.

n

the number of colors (≥ 1) to be in the palette.

  • terrain.colors()函式

Create a vector of n contiguous colors.

n

the number of colors (≥ 1) to be in the palette.

  • cm.colors()函式

Create a vector of n contiguous colors.

  • topo.colors()函式

Create a vector of n contiguous colors.


pch

Either an integer specifying a symbol or a single character to be used as the default in plotting points. See points for possible values and their interpretation. Note that only integers and single-character strings can be set as a graphics parameter (and not NA nor NULL).

cex

A numerical value giving the amount by which plotting text and symbols should be magnified relative to the default.

mfcol, mfrow

A vector of the form c(nr, nc). Subsequent figures will be drawn in an nr-by-nc array on the device by columns (mfcol), or rows (mfrow), respectively.

bg

The color to be used for the background of the device region. 

lty

The line type. Line types can either be specified as an integer (0=blank, 1=solid (default), 2=dashed, 3=dotted, 4=dotdash, 5=longdash, 6=twodash) or as one of the character strings "blank", "solid", "dashed", "dotted", "dotdash", "longdash", or "twodash", where "blank" uses ‘invisible lines’ (i.e., does not draw them).

bty

A character string which determined the type of box which is drawn about plots. If bty is one of "o" (the default), "l", "7", "c", "u", or "]" the resulting box resembles the corresponding upper case letter. A value of "n" suppresses the box.

las

numeric in {0,1,2,3}; the style of axis labels.

0:always parallel to the axis [default],

1:always horizontal,

2:always perpendicular to the axis,

3:always vertical.

  • legend()函式

This function can be used to add legends to plots. Note that a call to the function locator(1) can be used in place of the x and y arguments.

legend

a character or expression vector of length ≥ 1 to appear in the legend. Other objects will be coerced by as.graphicsAnnot.

col

the color of points or lines appearing in the legend.

lty, lwd

the line types and widths for lines appearing in the legend. One of these two must be specified for line drawing.

ncol

the number of columns in which to set the legend items (default is 1, a vertical legend).

bty

the type of box to be drawn around the legend. The allowed values are "o" (the default) and "n".

  • plot()函式

Generic function for plotting of R objects.

density()函式

The (S3) generic function density computes kernel density estimates. Its default method does so with the given kernel and bandwidth for univariate observations.

type

what type of plot should be drawn. Possible types are

"p" for points,

"l" for lines,

"b" for both,

"c" for the lines part alone of "b",

"o" for both ‘overplotted’,

"h" for ‘histogram’ like (or ‘high-density’) vertical lines,

"s" for stair steps,

"S" for other steps, see ‘Details’ below,

"n" for no plotting.

main

an overall title for the plot

x(y)lab

a title for the x(y) axis

  • lines()函式

A generic function taking coordinates given in various ways and joining the corresponding points with line segments.

 

  • barplot()函式

Creates a bar plot with vertical or horizontal bars.

horiz

a logical value. If FALSE, the bars are drawn vertically with the first bar to the left. If TRUE, the bars are drawn horizontally with the first at the bottom.

beside

a logical value. If FALSE, the columns of height are portrayed as stacked bars, and if TRUE the columns are portrayed as juxtaposed bars

legend.text

a vector of text used to construct a legend for the plot, or a logical indicating whether a legend should be included. This is only useful when height is a matrix. In that case given legend labels should correspond to the rows of height; if legend.text is true, the row names of height will be used as labels if they are non-null.

border

the color to be used for the border of the bars. Use border = NA to omit borders. If there are shading lines, border = TRUE means use the same colour for the border as for the shading lines.

  • hist()函式

  • boxplot()函式

Produce box-and-whisker plot(s) of the given (grouped) values.

  • heatmap()函式

A heat map is a false color image (basically image(t(x))) with a dendrogram added to the left side and to the top. Typically, reordering of the rows and columns according to some set of values (row or column means) within the restrictions imposed by the dendrogram is carried out.

Rowv

determines if and how the row dendrogram should be computed and reordered.

Colv

determines if and how the column dendrogram should be reordered.

scale

character indicating if the values should be centered and scaled in either the row direction or the column direction, or none.

margins

numeric vector of length 2 containing the margins (see par(mar = *)) for column and row names, respectively.

  • pairs()函式

A matrix of scatterplots is produced.