CodeInfoNet

Learn programming on the go!

Subsetting and visualizing subsets with matplot

Transpose() function:

This simple mathematical method will be helpful for us in this scenario.

So we will just transpose the matrix FieldGoals and we will get the output as below:

Transpose

Now that we have transposed the matrix, we can expect that the output of matplot() function will give nice visuals. Let’s see.

Simple plotting

Ooops!! We’ve got only colourful numbers. Nothing to worry! That’s because we haven’t specified any parameter to customize our result.

There are multiple parameters that we can use. They are as explained below:

  1. type: this is to specify the type of plot. Ex. type = “b”
  2. pch: pch is nothing but the plotting characters. This parameter is used to specify which shapes/ symbols to be used to

Values of pch are stored internally as integers. The interpretation is:

  • NA_integer_: no symbol.
  • 0:18: S-compatible vector symbols.
  • 19:25: further R vector symbols.
  • 26:31: unused (and ignored).
  • 32:127: ASCII characters.
  • 128:255 native characters only in a single-byte locale and for the symbol font. (128:159 are only used on Windows.)
  • -32 … Unicode code point (where supported).

Ex. pch = 15:18

3. Col: this parameter is used to specify the vector of colour(s). It also expects the range of colours. Ex. col=c(1:4,6)

Note:  You don’t need to learn these parameters by heart. As I always tell to my reader’s that practice is the key to get better. Also, this function is not used in complex solutions. But it’s always good to have knowledge.

Sumit Rajguru

Back to top