Skip to content

Commit 64d2479

Browse files
committed
ggbiplot gains a clip argument
1 parent 011746e commit 64d2479

File tree

6 files changed

+43
-3
lines changed

6 files changed

+43
-3
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,5 @@ Encoding: UTF-8
3333
Language: en-US
3434
URL: https://github.com/friendly/ggbiplot, https://friendly.github.io/ggbiplot/
3535
BugReports: https://github.com/friendly/ggbiplot/issues
36-
RoxygenNote: 7.2.3
36+
RoxygenNote: 7.3.2
3737
LazyData: true

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## Version 0.6.3
22

33
- Fix axis label spacing
4+
- `ggbiplot` gains a `clip` argument to control if points, labels, etc. are clipped to the axis limits.
45

56
## Version 0.6.2
67

R/ggbiplot.r

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@
116116
#' @param varname.adjust Adjustment factor the placement of the variable names, >= 1 means farther from the arrow
117117
#' @param varname.abbrev logical; whether or not to abbreviate the variable names, using \code{\link{abbreviate}}.
118118
#' @param axis.title character; the prefix used as the axis labels. Default: \code{"PC"}.
119+
#' @param clip should geoms be clipped at the axis limits? Default: "on"
119120
#' @param ... other arguments passed down
120121
#'
121122
#' @import ggplot2
@@ -197,11 +198,12 @@ ggbiplot <- function(pcobj,
197198
varname.color = "black",
198199
varname.abbrev = FALSE,
199200
axis.title = "PC",
201+
clip = "on",
200202
...)
201203
{
202204

203205
if(length(choices) > 2) {
204-
warning("choices = ", choices, " is not of length 2. Only the first 2 will be used")
206+
warning("choices = ", choices, " of length", length(choices), " not of length 2. Only the first 2 will be used")
205207
choices <- choices[1:2]
206208
}
207209

@@ -309,7 +311,7 @@ ggbiplot <- function(pcobj,
309311
g <- ggplot(data = df.u, aes(x = xvar, y = yvar)) +
310312
xlab(u.axis.labs[1]) +
311313
ylab(u.axis.labs[2]) +
312-
coord_equal()
314+
coord_equal(clip = clip)
313315

314316
# Draw either labels or points
315317
if(!is.null(df.u$labels)) {

examples/wine-robpca.R

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
library(rospca)
2+
library(ggbiplot)
3+
data(wine, package = "ggbiplot")
4+
5+
wine.pca <- prcomp(wine, scale=TRUE)
6+
7+
ggbiplot(wine.pca,
8+
obs.scale = 1, var.scale = 1,
9+
groups = wine.class,
10+
varname.size = 4,
11+
ellipse = TRUE,
12+
circle = TRUE) +
13+
labs(fill = "Cultivar", color = "Cultivar") +
14+
theme(legend.direction = 'horizontal', legend.position = 'top')
15+
16+
wine.rpca <- robpca(wine, k = 2, scale=TRUE)
17+
names(wine.rpca)
18+
19+
# [1] "loadings" "eigenvalues" "scores" "center" "k" "H0" "H1" "alpha" "h"
20+
# [10] "sd" "od" "cutoff.sd" "cutoff.od" "flag.sd" "flag.od" "flag.all"
21+
22+
class(wine.rpca)
23+
# list
24+
25+
diagPlot(wine.rpca)
26+
27+
wine.rpca$loadings
28+
29+
30+
#ggbiplot(wine.rpca)
31+
32+
33+

man/ggbiplot.Rd

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/ggscreeplot.Rd

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)