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

Drawing margin setting and layout in R language

2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article mainly introduces "the drawing margin setting and layout of R language". In the daily operation, I believe that many people have doubts about the drawing margin setting and layout of R language. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the doubts of "R language drawing margin setting and layout"! Next, please follow the editor to study!

I. drawing and margin area setting

Through the par parameters, reasonable adjustment of the size of the drawing area, the size of the inner and outer margins, can better display the graphics.

A simple example is as follows:

# outer margin margin setting, bottom left, top right; mai (inch margin)

Par (oma=c (3pm 3pm 3pm 3))

# left top right omi (inch margin) under the inner margin margin setting

Par (mar=c) + 0.1) # (coordinates) after the title is exceeded, it can be set appropriately.

# the first element is the distance from the axis position to the axis label, in terms of text line height. The second element is the distance from the axis position to the coordinate scale label. The third element is the distance between the position of the axis and the axis actually drawn, usually 0.

Par (mgp=c (4pm 2pm 0.5)) # adjust according to the situation

Plot (1PUR 10) BTY = "n") # does not draw the frame, which is convenient for later display.

# display of drawing area

Text (3 red 7, "drawing area", col= "red", cex=2)

Text (4pr 9, "WeChat: a little early", col= "red", cex=1)

Box ("plot", col= "red", lty= "dotted")

# inside margin display

Mtext ("inside margin", side=3,line=2,cex=2,col= "green")

Box ("figure", lty= "solid", col= "green")

# external margin display outer=TRUE

Mtext ("margin", side=1,line=1,cex=2,col= "blue", outer=TRUE,adj=0)

Box ("outer", col= "blue")

Second, page graphic layout

When drawing, sometimes you need to cut the drawing area and then show N (> = 2) graphics, which can be set using the par and layout parameters.

1) par parameters

Simple example:

Par (mfrow=c (2jue 2)) # splits the canvas into 2x2 patterns

Par (mfrow=c (3jue 1)) # splits the canvas into 3 lines and 1 column pattern

Plot (1:10); plot (1:10); boxplot (1pur100)

2) layout parameters

Layout (mat), mat is a matrix, the number of mat elements determines that an output device is equally divided into several parts, in which the same element is a piece.

Mat uses a matrix to set the partition of the window. The 0 element of the matrix indicates that the position is not drawn, and the non-0 element must include a continuous integer value starting from 1, such as: 1. N, sets the order of graphics by the size of non-zero elements.

Widths is used to set the width of different columns of the window, and heights sets the height of different rows.

Avatar 0 does not draw, figure1 occupies a grid in the upper left corner, and the first two squares in the second row belong to the three squares in which figure2,figure3 occupies the bottom row.

Layout (matrix (c (1, 2, 3, 0, 3, 3), nr=3))

Layout.show (3)

B: it is divided according to the matrix number, and the same number is the same piece.

Layout (matrix (c (1pur3), 2 (2)

Layout.show (3) # display layout number

C: sets the width and height ratio of the block

M

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

Internet Technology

Wechat

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

12
Report