Skip to content

Commit

Permalink
add u_angle parameter to allow changing url angle #62
Browse files Browse the repository at this point in the history
  • Loading branch information
GuangchuangYu committed May 20, 2019
1 parent 0ba11f9 commit 5d8ce36
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 17 deletions.
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@ install:
cd ..;\
R CMD INSTALL $(PKGNAME)_$(PKGVERS).tar.gz

check: build
cd ..;\
Rscript -e 'rcmdcheck::rcmdcheck("$(PKGNAME)_$(PKGVERS).tar.gz", args="--as-cran")'
check:
Rscript -e 'devtools::check()'

# check: build
# cd ..;\
# Rscript -e 'rcmdcheck::rcmdcheck("$(PKGNAME)_$(PKGVERS).tar.gz", args="--as-cran")'

check2: build
cd ..;\
Expand Down
18 changes: 11 additions & 7 deletions R/sticker.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
##' @param u_color color for url
##' @param u_family font family for url
##' @param u_size text size for url
##' @param u_angle angle for url
##' @param white_around_sticker default to FALSE. If set to TRUE, it puts
##' white triangles in the corners
##' @param ... additional parameter to geom_pkgname
##' @param filename filename to save sticker
##' @param asp aspect ratio, only works if subplot is an image file
##' @param dpi plot resolution
Expand All @@ -42,12 +46,12 @@
##' p <- ggplot(aes(x = mpg, y = wt), data = mtcars) + geom_point()
##' p <- p + theme_void() + theme_transparent()
##' sticker(p, package="hexSticker")
##' @author guangchuang yu
##' @author Guangchuang Yu
sticker <- function(subplot, s_x=.8, s_y=.75, s_width=.4, s_height=.5,
package, p_x=1, p_y=1.4, p_color="#FFFFFF", p_family="Aller_Rg", p_size=8,
h_size=1.2, h_fill="#1881C2", h_color="#87B13F",
spotlight=FALSE, l_x=1, l_y=.5, l_width=3, l_height=3, l_alpha=0.4,
url = "", u_x=1, u_y=0.08, u_color="black", u_family="Aller_Rg", u_size=1.5,
url = "", u_x=1, u_y=0.08, u_color="black", u_family="Aller_Rg", u_size=1.5, u_angle=30,
white_around_sticker = FALSE, ...,
filename = paste0(package, ".png"), asp=1, dpi = 300) {

Expand All @@ -69,7 +73,7 @@ sticker <- function(subplot, s_x=.8, s_y=.75, s_width=.4, s_height=.5,

sticker <- sticker + geom_pkgname(package, p_x, p_y, p_color, p_family, p_size, ...)

sticker <- sticker + geom_url(url, x=u_x, y = u_y, color = u_color, family = u_family, size=u_size)
sticker <- sticker + geom_url(url, x=u_x, y = u_y, color = u_color, family = u_family, size=u_size, angle=u_angle)

if (white_around_sticker)
sticker <- sticker + white_around_hex(size = h_size)
Expand Down Expand Up @@ -237,19 +241,19 @@ white_around_hex <- function(size = 1.2) {
y_vertices <- 1+c(0.5, -0.5, -1, -0.5, 0.5, 1)

list(
ggplot2::geom_polygon(mapping = aes(x = x, y = y),
ggplot2::geom_polygon(mapping = aes_(x = ~x, y = ~y),
data = data.frame(x = c(x_lims[1], x_lims[1], x_vertices[6]),
y = c(y_vertices[1], y_lims[2], y_lims[2])),
fill = 'white'),
ggplot2::geom_polygon(mapping = aes(x = x, y = y),
ggplot2::geom_polygon(mapping = aes_(x = ~x, y = ~y),
data = data.frame(x = c(x_vertices[6], x_lims[2], x_lims[2]),
y = c(y_lims[2], y_lims[2], y_vertices[5])),
fill = 'white'),
ggplot2::geom_polygon(mapping = aes(x = x, y = y),
ggplot2::geom_polygon(mapping = aes_(x = ~x, y = ~y),
data = data.frame(x = c(x_vertices[3], x_lims[2], x_lims[2]),
y = c(y_lims[1], y_vertices[4], y_lims[1])),
fill = 'white'),
ggplot2::geom_polygon(mapping = aes(x = x, y = y),
ggplot2::geom_polygon(mapping = aes_(x = ~x, y = ~y),
data = data.frame(x = c(x_lims[1], x_lims[1], x_vertices[3]),
y = c(y_lims[1], y_vertices[2], y_lims[1])),
fill = 'white')
Expand Down
2 changes: 0 additions & 2 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,6 @@ sticker(p, package="hexSticker", p_size=8, s_x=1, s_y=.75, s_width=1.3, s_height
[<img src="https://raw.githubusercontent.com/Bioconductor/BiocStickers/master/pRoloc/pRolocGUI.png" height="120"/>](https://github.com/Bioconductor/BiocStickers/tree/master/pRoloc)
[<img src="https://github.com/Yue-Jiang/pzfx/blob/master/man/figures/logo.png" height="120"/>](https://github.com/Yue-Jiang/pzfx)
[<img src="https://raw.githubusercontent.com/justinmillar/r-gators-hex/master/r-gators.png" height="120"/>](https://github.com/justinmillar/r-gators-hex)
[<img src="https://raw.githubusercontent.com/markhogue/RadData/man/figures/RadData.png" height="120"/>](https://github.com/markhogue/RadData)
[<img src="https://raw.githubusercontent.com/markhogue/radsafer/man/figures/radsafer.png" height="120"/>](https://github.com/markhogue/radsafer)
[<img src="https://raw.githubusercontent.com/ellessenne/rsimsum/master/man/figures/hex.png" height="120"/>](https://github.com/ellessenne/rsimsum)
[<img src="https://github.com/thiyangt/seer/blob/master/logo/seer.png" height="120"/>](https://github.com/thiyangt/seer/blob/master/logo/seer.png)
[<img src="https://raw.githubusercontent.com/danielmarcelino/SenadoBR/master/inst/figures/SenadoBR-logo.png" height="120"/>](https://github.com/danielmarcelino/SenadoBR)
Expand Down
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,6 @@ sticker(p, package="hexSticker", p_size=8, s_x=1, s_y=.75, s_width=1.3, s_height
[<img src="https://raw.githubusercontent.com/Bioconductor/BiocStickers/master/pRoloc/pRolocGUI.png" height="120"/>](https://github.com/Bioconductor/BiocStickers/tree/master/pRoloc)
[<img src="https://github.com/Yue-Jiang/pzfx/blob/master/man/figures/logo.png" height="120"/>](https://github.com/Yue-Jiang/pzfx)
[<img src="https://raw.githubusercontent.com/justinmillar/r-gators-hex/master/r-gators.png" height="120"/>](https://github.com/justinmillar/r-gators-hex)
[<img src="https://raw.githubusercontent.com/markhogue/RadData/man/figures/RadData.png" height="120"/>](https://github.com/markhogue/RadData)
[<img src="https://raw.githubusercontent.com/markhogue/radsafer/man/figures/radsafer.png" height="120"/>](https://github.com/markhogue/radsafer)
[<img src="https://raw.githubusercontent.com/ellessenne/rsimsum/master/man/figures/hex.png" height="120"/>](https://github.com/ellessenne/rsimsum)
[<img src="https://github.com/thiyangt/seer/blob/master/logo/seer.png" height="120"/>](https://github.com/thiyangt/seer/blob/master/logo/seer.png)
[<img src="https://raw.githubusercontent.com/danielmarcelino/SenadoBR/master/inst/figures/SenadoBR-logo.png" height="120"/>](https://github.com/danielmarcelino/SenadoBR)
Expand Down
14 changes: 11 additions & 3 deletions man/sticker.Rd

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

0 comments on commit 5d8ce36

Please sign in to comment.