autoplot的scaling参数作用解析及Distance biplot绘制方法咨询
scaling in autoplot() for PCA Biplots (USArrests Example) Great question—let's break down how ggfortify::autoplot() handles biplot scaling, especially compared to base R's biplot(), and how to get the exact Distance biplot (scaling = 1) you're looking for.
First, a quick recap of the two biplot types from Borcard et al. (2011):
- Distance Biplot (scaling = 1): Prioritizes preserving the Euclidean distance between sample points (matching the standardized original data). Loading vectors show how variables contribute to the principal components.
- Correlation Biplot (scaling = 2): Focuses on showing correlations between variables (via the angle between loading vectors) and approximating original variable values via the dot product of sample scores and loadings.
How Base R's biplot() Maps to These Types
Your base R examples are exactly right:
- Distance biplot (scaling = 1):
biplot(prcomp(USArrests, scale = TRUE), scale=0) - Correlation biplot (scaling = 2):
biplot(prcomp(USArrests, scale = TRUE), pc.biplot=TRUE)
How autoplot() Matches (and Controls) These Biplots
The ggfortify::autoplot() function mirrors base R's parameter behavior directly—you just need to map the arguments correctly:
Correlation Biplot (scaling = 2)
Your firstautoplotcall usespc.biplot=TRUE, which is exactly equivalent to the base R correlation biplot:ggplot2::autoplot(stats::prcomp(USArrests, scale=TRUE), pc.biplot=TRUE, label = TRUE, loadings.label = TRUE)This scales sample scores and loadings to emphasize variable correlations and approximate original variable values.
Distance Biplot (scaling = 1)
Yes! You absolutely can draw this withautoplot()—and you already did it in your second example:ggplot2::autoplot(stats::prcomp(USArrests, scale=TRUE), scale=0, label = TRUE, loadings.label = TRUE)This matches the base R
scale=0call, preserving sample distances (the core of a Distance biplot) while displaying loadings as variable contributions to principal components.Other
scalingValues inautoplot()scale=1: A middle-ground scaling that balances sample distance preservation and variable correlation visibility. Both samples and loadings are scaled to equalize their "weight" in the plot.scale=2: Scales loadings to reflect the variance of original variables, while adjusting sample scores to align with this. This emphasizes variable magnitude alongside correlations.
Quick Cheat Sheet
| Biplot Type | Base R biplot() Call | autoplot() Equivalent |
|---|---|---|
| Distance (scaling=1) | biplot(..., scale=0) | autoplot(..., scale=0) |
| Correlation (scaling=2) | biplot(..., pc.biplot=TRUE) | autoplot(..., pc.biplot=TRUE) |
内容的提问来源于stack exchange,提问作者H.F.S C.

