Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis of plot drawing in R language

2025-01-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

What this article shares to you is the example analysis of plot drawing in R language. The editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.

Parameters in the drawing function:

Graphic element parameters:

Pch: used to display the coordinates of a point, either a character or an integer from 0 to 25. Such as: pch= "+", pch=1

Lty: line type. Such as: lty=2,lty=1

Lwd: line width. Such as: lwd=2

Col: color settings for points, lines, text, and filled areas. Col.axis, col.sub, and col.main correspond to axis dimensions, subtitles, and main title colors, respectively. Such as col=2, col.sub=2

Font: font settings. Same as above

Cex: character expansion rate, which represents the ratio of the expected character size (including drawing characters) to the default size.

The argument to the plot () function:

Xlim and ylim: denote the length of the x-axis and y-axis, for example: plot (passign, type= "l", xlim=c (0100)) means that the x-axis coordinates are from 0 to 0100.

Add=TRUE forces the function to run as a low-level drawing function, loading new graphic elements on the current graph (only suitable for some functions).

Axes=FALSE forbids the generation of axes | it is useful when you want to use the function axis () to draw personalized axes. The default value is axes=TRUE, which means the axis is generated.

Log:log= "x", log= "y", log= "xy" make the x axis, the y axis, or both logarithmic axes, which works for many graphs, but not all.

The type= parameter type= controls the type of output graphics, especially lines:

Type= "p" displays only dots (default)

Type= "l" displays lines

Type= "b" (simultaneously) displays dots and lines

Type= "o" overlays the dot on the line

Type= "h" draws a vertical line from point to zero axis (x axis) (high density (high-density))

Type= "s"

Type= "S" step chart. In the first form, the top of the vertical line matches the data points; in the second form, the bottom matches.

Type= "n" graphics are not displayed. However, the axis is still displayed (the default), and the coordinates are still set by data. This is very suitable for drawing later with low-level drawing functions.

Xlab=string

Ylab=string sets labels for the x and y axes. You can use these parameters to modify the default label. The default label is often the name of the object used in the advanced drawing function.

Legend (x, y, legend,...): adds a legend (legend) to a specific location in the current diagram. Identification characters, line formats, colors, etc., are all annotated by the tags in the character vector legend. Another parameter v that contains the corresponding value of the drawing units (a vector that is consistent with the length of the legend) must be given:

Legend (, fill=v)

Fill the color of the box

Legend (, col=v)

The color of a dot or line

Legend (, lty=v)

Line styl

Legend (, lwd=v)

Line width

Legend (, pch=v)

Identification character (character vector)

Example:

Plot (passign, type= "l", col=1, lwd=3, lty=1, xlim=c (0100))

Lines (psubmit, type= "l", col=2, lwd=3, lty=2)

Legend (50150, legend=c ("assignTo", "submitBy"), col=1:2, lwd=3, lty=c (1mem2))

The above is the example analysis of plot drawing in R language. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report