# Dimension Reduction - Plot - Component Plot

Chart the first two components or factors from a principal components analysis or factor analysis.

Chart the first two components or factors from a principal components analysis or factor analysis (created, for example, with Dimension Reduction - Principal Components Analysis).

## How to Create

**As a separate output in your report**

There are two methods to create the plot in this case.

- Add the object with
**Create > Dimension Reduction > Plot > Component Plot**. Then in the newly created component plot, view the Inputs tab of the Object Inspector and select the desired PCA or factor analysis output from the dropbox labeled Principal components analysis in the INPUTS subsection. - In the Object Inspector of a PCA or factor analysis output, click the Component plot extension button. This extension button can be found under
**Inputs > PLOT > Component plot**. The extension button will create a new R output with the Component plot in the same group (folder) where the PCA or factor analysis is contained.

**Within your PCA output created by Dimension Reduction - Principal Components Analysis**

- Change the
**Inputs > Display**drop-down to**Component Plot**

## Example

**Example output**:

**Example input**:

## Options

**Principal components analysis** An R Output containing a factor analysis or principal components analysis. This does not need to be created with Dimension Reduction - Principal Components Analysis (you can make your own factor analysis or PCA), but the item does need to have a property called `loadings`.

**Show variable labels on plot** Whether or not the labels found in the loadings will be displayed in the chart.

## Code

```
form.setHeading("Component Plot");
form.dropBox({name: "inputItem", label: "Principal components analysis", types: ["R"],
prompt: "Output of PCA"});
form.checkBox({name: "formShowLabels", label: "Show variable labels on plot", default_value: true});
```

```
library(flipDimensionReduction)
component.plot <- ComponentPlot(QInputs(inputItem), show.labels = formShowLabels)
```