Articles

Affichage des articles du septembre, 2016

Difference between par(fig=c()) , par(mfrow=), par(mfcol=c()), and layout() to plot several plots in the same page

Image
There are several mechanisms that can be used to plot several plots in the same page. You can use mfrow(), par(fig=c()) or layout(). Trying the 3 different methods, a big difference has been noted that is not clearly stated in the documentation. layout() function and par(mfrow=) changes the par("cex") whereas par(fig=c()) does not change it. In the documentation of par: In a layout with exactly two rows and columns the base value of "cex" is reduced by a factor of 0.83: if there are three or more of either rows or columns, the reduction factor is 0.66. The change or not of par("cex") is important if mtext() is used because it does not used by default the par("cex") parameter. It must be forced to use it.

Again how to manage indices and exposants and variable name in plot legend

Image
labNames <- c('xLab','yLab') par(mar=c(4, 4, 1, 1)+0.4) scaley <- 100000 xlab <- as.expression(bquote(.(format(scaley, digits = 10, scientific = FALSE, big.mark = " ")) ~ x^2)) ylab <- as.expression(bquote(.(labNames[2]) ~ italic("Here in\" italic")^"-2" * "" [Essai])) L <- list(x=1:10,  xlab = xlab, ylab = ylab) do.call(plot, L) Try it; You will see how to use a regular R expression with .() How to put text in exposant with ^ How to paste text with * (no space between) or ~ (adding a space) How to put text in indice with [] How to stop exposant for next characters with * "" How to put text in italic with italic() How to add a " character with \" How to format large number with format()

Read the content of clipboard

For example, copy a able from excel and to get data, use: In windows: x <- read.table(file = 'clipboard', sep = '\t', header = TRUE) In macOSx: x <- read.table(file = pipe('pbpaste'), sep = '\t', header = TRUE)