Plotting options

So far in the examples presented, the display of the plots has been just the default one. Of course, there are multiple possibilities of customizing this. For the purpose of extension, only the following listed ones will be covered:

  • col: This is a string vector that defines the color. It can be written either as the color name (red, blue, and so on) or by its hexadecimal code. If the col argument has a vector shorter than the number of elements to plot, it will be recycled as explained in Chapter 2, First Steps towards Programming in R.
  • pch: This argument defines the shape of the points plotted. The different options are numerically coded. For a complete reference, visit http://www.endmemo.com/program/R/pchsymbols.php.

Consequently, pch receives a numeric vector in which each number corresponds to one symbol according to the preceding image. This is similar to col, where the vector is recycled if needed:

  • main: This is the title of the plot.
  • xlab: This is the label of the horizontal axis.
  • ylab: This is the label of the vertical axis.
  • xlim: This specifies the lower and upper limit of the horizontal axis. A numeric vector of a 2 length must be passed to this argument. Here the first value indicates the lower limit, and the second value indicates the upper one.
  • ylim: This is identical to xlim but for the vertical axis.
  • cex: As stated in the R help, A numerical value giving the amount by which plotting text and symbols should be magnified relative to the default (https://stat.ethz.ch/R-manual/R-devel/library/graphics/html/par.html). Although the explanation might seem complex, it is just a numeric value to control the relative size of the elements inside the plot.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset