R language Low-level drawing function-rect

Source: Internet
Author: User

The RECT function is used to add a rectangle to a graph, so you can draw a rectangle by specifying the position of the lower-left and upper-right coordinates.

Basic usage:

Plot (1:5, 1:5, Xlim = C (0,6), Ylim = C (0,6), type = "n") rect (xleft = 1, Ybottom = 1, xright = 5, ytop = 5)

As follows:

Xleft, Ybottom, Xright, Ytop supports setting multiple values at once, creating multiple rectangles, using the following:

Plot (1:5, 1:5, Xlim = C (0,6), Ylim = C (0,6), type = "n") rect (Xleft = C (1, 2), Ybottom = C (1, 2), Xright = C (5, 4), ytop = C (5, 4))

As follows:

Parameter settings:

Border: Sets the color of the rectangle border, default to "Black", supports setting different values for multiple rectangles

code example:

Plot (1:5, 1:5, Xlim = C (0,6), Ylim = C (0,6), type = "n") rect (Xleft = C (1, 2), Ybottom = C (1, 2), Xright = C (5, 4), ytop = C (5, 4), border = C ("Red", "Blue"))

As follows:

Col: Sets the fill color of the rectangle, default is null, indicates no fill color, supports setting different values for multiple rectangles

Plot (1:5, 1:5, Xlim = C (0,6), Ylim = C (0,6), type = "n") rect (Xleft = C (1, 2), Ybottom = C (1, 2), Xright = C (5, 4), ytop = C (5, 4), col = C ("Pink", "green"))

As follows:

Density and angle: With use, set to fill the rectangle with lines, angle set the angle of the line, default to three, density set the density of the fill line, the larger the more dense

code example:

As follows:

LWD: Sets the width of all lines in the rectangle

code example:

Plot (1:5, 1:5, Xlim = C (0,6), Ylim = C (0,6), type = "n") rect (xleft = 1, Ybottom = 1, xright = 5, ytop = 5, Angle = $, de Nsity = 2, LWD = 3)

As follows:

Lty: Sets the type of all lines in the rectangle

code example:

Plot (1:5, 1:5, Xlim = C (0,6), Ylim = C (0,6), type = "n") rect (xleft = 1, Ybottom = 1, xright = 5, ytop = 5, Angle = $, de Nsity = 2, LWD = 2, lty = 3)

As follows:

R language Low-level drawing function-rect

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.