官术网_书友最值得收藏!

Using par to beautify a plot in R

One quick and easy way to edit a plot is by generating the plot in R and then using Inkspace or any other software to edit it. We can save some valuable time if we know some basic edits that can be applied on a plot by setting them in a par() function. All the available options to edit a plot can be studied in detail by typing ?par in the command window.

How to do it…

In the following code, I have highlighted some commonly used parameters:

x=c(1:10)
y=c(1:10)
par(bg = "#646989", las = 1, col.lab = "black", col.axis = "white",bty = "n",cex.axis = 0.9,cex.lab= 1.5)
plot(x,y, pch = 20, xlab = "fake x data", ylab = "fake y data")

How it works…

Under the par() function, we have set the background color using the bg = argument. The las = argument changes the orientation of the labels. The col.lab and col.axis arguments are used to specify the color of the labels as well as the axis. The cex argument is used to specify the size of the labels and axis. The bty argument is used to specify the box style in R.

主站蜘蛛池模板: 石景山区| 潼关县| 平南县| 克拉玛依市| 进贤县| 福建省| 城步| 静海县| 南涧| 格尔木市| 三穗县| 广水市| 平阳县| 思南县| 龙泉市| 兴文县| 交口县| 茶陵县| 中西区| 丰镇市| 自治县| 新乡市| 泸水县| 介休市| 平南县| 吉木萨尔县| 唐河县| 昌宁县| 明星| 崇阳县| 湖口县| 新龙县| 琼结县| 华阴市| 荥经县| 陇川县| 榆树市| 井冈山市| 荔浦县| 茂名市| 邛崃市|