Skip to content

Commit

Permalink
option for setting phylopic width
Browse files Browse the repository at this point in the history
  • Loading branch information
GuangchuangYu committed Dec 5, 2019
1 parent aec9e2f commit 39882da
Show file tree
Hide file tree
Showing 16 changed files with 97 additions and 34 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: ggimage
Title: Use Image in 'ggplot2'
Version: 0.2.5
Version: 0.2.6
Authors@R: person("Guangchuang", "Yu",
email = "guangchuangyu@gmail.com",
role = c("aut", "cre"),
Expand Down Expand Up @@ -34,5 +34,5 @@ URL: https://github.com/GuangchuangYu/ggimage
BugReports: https://github.com/GuangchuangYu/ggimage/issues
Encoding: UTF-8
LazyData: true
RoxygenNote: 6.1.1
RoxygenNote: 7.0.2
Roxygen: list(markdown = TRUE)
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@

## ggimage 0.2.6

+ change default image width to 256 for phylopic and it can be set to other values by e.g. `options(phylopic_width=512)` (2019-12-05, Thu)
- <https://github.com/YuLab-SMU/treedata-book/issues/1>

## ggimage 0.2.5

+ `phylopic_uid` now return a data.frame (2019-11-29, Fri)
Expand Down
4 changes: 2 additions & 2 deletions R/geom_image.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
geom_ggtree_image <- function() {
## geom_ggtree_image <- function() {

}
## }


##' geom layer for visualizing image files
Expand Down
12 changes: 7 additions & 5 deletions R/geom_phylopic.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@
##'
##' @title geom_phylopic
##' @inheritParams geom_pokemon
##' @param height size (by height) of phylopic image to be used
##' @return ggplot2 layer
##' @export
##' @author Guangchuang Yu
geom_phylopic <- function(mapping=NULL, data=NULL, inherit.aes=TRUE,
na.rm=FALSE, by="width", height = 512, ...) {
geom_image(mapping, data, inherit.aes=inherit.aes, na.rm=na.rm, ..., height = height, .fun = phylopic)
na.rm=FALSE, by="width", ...) {
geom_image(mapping, data, inherit.aes=inherit.aes, na.rm=na.rm, ..., .fun = phylopic)
}


phylopic <- function(id, height=512) {
paste0("http://phylopic.org/assets/images/submissions/", id, ".", height, ".png")
phylopic <- function(id) {
width <- getOption("phylopic_width")
if (is.null(width))
width <- 256
paste0("http://phylopic.org/assets/images/submissions/", id, ".", width, ".png")
}

phylopic_valid_id <- function(id) {
Expand Down
Binary file added inst/extdata/bulb.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 8 additions & 2 deletions man/geom_emoji.Rd

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

10 changes: 8 additions & 2 deletions man/geom_flag.Rd

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

10 changes: 8 additions & 2 deletions man/geom_icon.Rd

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

14 changes: 11 additions & 3 deletions man/geom_image.Rd

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

12 changes: 8 additions & 4 deletions man/geom_phylopic.Rd

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

10 changes: 8 additions & 2 deletions man/geom_pokemon.Rd

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

11 changes: 9 additions & 2 deletions man/geom_subview.Rd

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

10 changes: 8 additions & 2 deletions man/geom_twitchemote.Rd

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

10 changes: 8 additions & 2 deletions man/geom_worldcup2018.Rd

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

2 changes: 1 addition & 1 deletion man/reexports.Rd

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

6 changes: 3 additions & 3 deletions vignettes/ggimage.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ library("ggplot2")
library("ggimage")
set.seed(2017-02-21)
img <- list.files(system.file("extdata", package="ggimage"),
pattern="png", full.names=TRUE)
d <- data.frame(x = rnorm(10),
y = rnorm(10),
image = sample(c("https://www.r-project.org/logo/Rlogo.png",
"https://jeroenooms.github.io/images/frink.png"),
size=10, replace = TRUE)
image = sample(img, size=10, replace = TRUE)
)
ggplot(d, aes(x, y)) + geom_image(aes(image=image), size=.05)
Expand Down

0 comments on commit 39882da

Please sign in to comment.