plot_PCA | R Documentation |
plot_PCA is a replacement for plot.PCA. Out of this function I took the functionality that I need and added the functionality to emphasize points (variables or individuals). The function plots the variables or individuals information from the structure returned by the function PCA.
plot_PCA(
res,
var_ind = "ind",
axes = 1:2,
cex = 1,
font.std = 1,
pch.std = 20,
col.std = "black",
font.emp = 2,
pch.emp = pch.std,
col.emp = "red",
font.sel = font.std,
pch.sel = pch.std,
col.sel = col.std,
font.sup = 3,
pch.sup = 1,
col.sup = "blue",
show.sup = TRUE,
select = NULL,
emphasize = NULL,
invisible = NULL
)
res |
Structure that is the output of the function PCA |
var_ind |
Character string that indicates if variables ( |
axes |
Numeric vector with two integers indicating the dimensions that will be plotted. Default: |
cex |
Positive number indicating the size of symbols and labels. Default: |
font.std |
Positive integer indicating the font that is used for the standard labels (i.e. not for supplemental, selected or emphasized elements). See description of |
pch.std |
Positive integer indicating the plotting character that is used for the standard points (i.e. not for supplemental, selected or emphasized elements). See description of |
col.std |
Color specification for the standard elements (i.e. not for supplemental, selected or emphasized elements). See description of |
font.emp |
Positive integer indicating the font that is used for the labels of emphasized elements. See description of |
pch.emp |
Positive integer indicating the plotting character that is used for the emphasized points. See description of |
col.emp |
Color specification for emphasized elements. See description of |
font.sel |
Positive integer indicating the font that is used for the labels of selected elements. See description of |
pch.sel |
Positive integer indicating the plotting character that is used for the selected points. See description of |
col.sel |
Color specification for selected elements. See description of |
font.sup |
Positive integer indicating the font that is used for the labels of supplemental elements. See description of |
pch.sup |
Positive integer indicating the plotting character that is used for the supplemental points. See description of |
col.sup |
Color specification for supplemental elements. See description of |
show.sup |
Boolean indicating if supplemental elements should be shown. Default: |
select |
Character string with a selection criterion (see |
emphasize |
Character vector with the rownames or an integer vector with the sequence numbers of the active elements that should be emphasized (i.e. be given a different layout than the other elements). Default: NULL (i.e. none are emphasized) |
invisible |
Character vector with the rownames of the elements (active and supplemental) that are not shown. Default: NULL |
The select mechanism is taken over asis from the FactoMineR::PCA
function. The labels of selected elements will be plotted.
The authors Francois Husson husson@agrocampus-ouest.fr and Jeremy Mazet describe it as follows:
The select argument can be used in order to select a part of the elements (individuals if you draw the graph of individuals, or variables if you draw the graph of variables) that are drawn. For example, you can use:
select = 1:5
and then the elements 1:5
are drawn.
select = c("name1","name5")
and then the elements that have the names name1
and name5
are drawn.
select = "coord 10"
and then the 10 elements that have the highest (squared) coordinates on the 2 chosen dimensions are drawn.
select = "contrib 10"
and then the 10 elements that have the highest contribution on the 2 dimensions of your plot are drawn.
select = "cos2 5"
and then the 5 elements that have the highest cos2 on the 2 dimensions of your plot are drawn.
select = "dist 8"
and then the 8 elements that have the highest distance to the center of gravity are drawn.
NB. the following functionality is contained in plot.PCA but not described there:
select = "cos2 0.8"
and then the elements for which the sum of the cos2 on the 2 dimensions of your plot is greater than 0.8 are drawn.
All ideas come from the creators of the FactoMineR package. This implementation is mine and if you find any errors, these will be mine. In case of errors try using the original plot.PCA.
## Not run:
plot_PCA(res,cex=0.8,show.sup = F,emphasize = 'BU03620304',sel='contrib 6')
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.