Skip to content

Commit

Permalink
Remove GeomBeeswarm
Browse files Browse the repository at this point in the history
GeomPoint is sufficient and offset_beeswarm call
will be moved to PositionBeeswarm.
  • Loading branch information
csdaw committed Jun 24, 2021
1 parent 34c24c3 commit 09ed5a0
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 112 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
Expand Up @@ -11,6 +11,7 @@ Description: Provides two methods of plotting categorical scatter plots such
data at that region, and avoids over-plotting.
URL: https://github.com/eclarke/ggbeeswarm
BugReports: https://github.com/eclarke/ggbeeswarm/issues
Encoding: UTF-8
License: GPL (>=2)
Depends:
R (>= 3.0.0),
Expand All @@ -20,4 +21,4 @@ Imports:
vipor
Suggests:
gridExtra
RoxygenNote: 6.0.1
RoxygenNote: 7.1.1
2 changes: 0 additions & 2 deletions NAMESPACE
@@ -1,9 +1,7 @@
# Generated by roxygen2: do not edit by hand

export(GeomBeeswarm)
export(geom_beeswarm)
export(geom_quasirandom)
export(makeContent.beeswarm)
export(offset_beeswarm)
export(position_quasirandom)
import(ggplot2)
Expand Down
48 changes: 1 addition & 47 deletions R/geom-beeswarm.R
Expand Up @@ -46,7 +46,7 @@ geom_beeswarm <- function(
data = data,
mapping = mapping,
stat = stat,
geom = GeomBeeswarm,
geom = GeomPoint,
position = position,
show.legend = show.legend,
inherit.aes = inherit.aes,
Expand All @@ -60,49 +60,3 @@ geom_beeswarm <- function(
)
)
}

#' geom object for use in geom_beeswarm
#' @export
GeomBeeswarm <- ggplot2::ggproto("GeomBeeswarm", ggplot2::GeomPoint,
draw_panel = function(data, panel_params, coord, priority = c("ascending", "descending", "density", "random", "none"), cex=1, groupOnX=NULL, dodge.width=0, beeswarmArgs=list(), na.rm = FALSE) {
if (is.character(data$shape)) {
data$shape <- ggplot2::translate_shape_string(data$shape)
}
coords <- coord$transform(data, panel_params)
grid::gTree(
coords=coords,
priority=priority,
groupOnX=groupOnX,
dodge.width=dodge.width,
beeswarmArgs=beeswarmArgs,
gp=grid::gpar(
col = alpha(coords$colour, coords$alpha),
fill = alpha(coords$fill, coords$alpha),
# Stroke is added around the outside of the point
fontsize = coords$size * .pt + coords$stroke * .stroke / 2,
lwd = coords$stroke * .stroke / 2
),
cl = "beeswarm"
)
}
)

#' grid::makeContent function for the grobTree of GeomBeeswarm objects
#'
#' @param self a beeswarm gridTree grob
#' @return a pointsGrob
#' @export
makeContent.beeswarm <- function(self) {
oSize<-c(
grid::convertX(grid::grobWidth(grid::textGrob('o',gp=grid::gpar(cex=1))),'native'),
grid::convertY(grid::grobHeight(grid::textGrob('o',gp=grid::gpar(cex=1))),'native')
)
coords<-offset_beeswarm(self$coords,priority=self$priority,cex=self$coords$size[1],groupOnX=self$groupOnX,dodge.width=self$dodge.width,beeswarmArgs=self$beeswarmArgs,oSize=oSize)

grid::pointsGrob(
coords$x, coords$y,
pch = coords$shape
)
}


14 changes: 0 additions & 14 deletions man/GeomBeeswarm.Rd

This file was deleted.

32 changes: 21 additions & 11 deletions man/geom_beeswarm.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 23 additions & 11 deletions man/geom_quasirandom.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion man/ggbeeswarm.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 0 additions & 17 deletions man/makeContent.beeswarm.Rd

This file was deleted.

18 changes: 14 additions & 4 deletions man/offset_beeswarm.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 12 additions & 4 deletions man/position_quasirandom.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 09ed5a0

Please sign in to comment.