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

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.

主站蜘蛛池模板: 若尔盖县| 酒泉市| 广水市| 通州区| 蓝山县| 华池县| 丁青县| 黔西县| 哈巴河县| 徐水县| 松溪县| 安乡县| 邻水| 珠海市| 林甸县| 定陶县| 登封市| 闸北区| 洞头县| 栾城县| 拉孜县| 万宁市| 平原县| 新平| 会宁县| 南江县| 尚志市| 区。| 清镇市| 闻喜县| 武功县| 临颍县| 普洱| 塔河县| 新兴县| 永德县| 云浮市| 调兵山市| 景东| 满城县| 顺昌县|