Skip to content

Commit

Permalink
fix label spacing; bump pkg version
Browse files Browse the repository at this point in the history
  • Loading branch information
friendly committed Apr 24, 2024
1 parent 21fa1e5 commit 011746e
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 3 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Package: ggbiplot
Type: Package
Title: A Grammar of Graphics Implementation of Biplots
Version: 0.6.2
Date: 2024-01-06
Version: 0.6.3
Date: 2024-04-24
Authors@R: c(
person(c("Vincent", "Q."), "Vu", , "vqv@stat.osu.edu", role = c("aut"),
comment = c(ORCID = "0000-0002-4689-0497")),
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## Version 0.6.3

- Fix axis label spacing

## Version 0.6.2

This is a modest upgrade to the initial release, adding a number of features.
Expand Down
2 changes: 1 addition & 1 deletion R/ggbiplot.r
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ ggbiplot <- function(pcobj,

# Change the title labels for the axes
if(obs.scale == 0) {
u.axis.labs <- paste('standardized', axis.title, choices, sep='')
u.axis.labs <- paste('standardized ', axis.title, choices, sep='')
} else {
u.axis.labs <- paste(axis.title, choices, sep='')
}
Expand Down
Binary file modified discussion/biplot-packages.xlsx
Binary file not shown.
46 changes: 46 additions & 0 deletions examples/ggvector.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
#' Draw labeled vectors in a ggplot scene
#'
#' @param x,y coordinates of vector ends
#' @param label text labels for vector ends
#' @param scale scale factor for vectors
#' @param origin origin of vectors
#' @param arrow_style style for the vector arrows
#' @param color colors for vectors
#' @param linewidth linewidth for vectors
#' @param adjust adjustment offset for labels
#' @param size text size for labels
#'
#' @return
#' @export
#'
#' @examples
ggvector <- function(x, y, label,
scale = 1,
origin = c(0, 0),
arrow_style,
color,
linewidth = 1.4,
adjust = 1.25,
size = 3
){

if(missing(arrow_style)) arrow_style <- arrow(length = unit(1/2, 'picas'),
type="closed",
angle=15)
# Variables for text label placement
df <- data.frame(x = x, y = y, label = label)
df$angle <- with(df, (180/pi) * atan(y / x))
df$hjust <- with(df, (1 - adjust * sign(x)) / 2)

geom_segment(data = df,
aes(x = origin[1], y = origin[2],
xend = x, yend = y),
arrow = arrow_style,
color = color,
linewidth = linewidth) +
geom_text(data = df,
aes(label = label, x = x, y = y,
angle = angle, hjust = hjust),
color = color, size = size)

}

0 comments on commit 011746e

Please sign in to comment.