Skip to content

Commit

Permalink
Work around scale_y_continuous() behavior in {ggplot2@3.5} (#488)
Browse files Browse the repository at this point in the history
  • Loading branch information
schloerke committed Feb 12, 2024
1 parent b889015 commit b062ddf
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,4 @@ Encoding: UTF-8
Language: en-US
RdMacros: lifecycle
Remotes:
tidyverse/ggplot2
tidyverse/ggplot2@rc/3.5.0
11 changes: 10 additions & 1 deletion R/ggnet.R
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ ggnet <- function(

y = ifelse(is_dir == "digraph", "directed", "undirected")
z = c("indegree" = "in", "outdegree" = "out", "degree" = "all", "freeman" = "all")[x]
data$weight = igraph::degree(igraph::graph.adjacency(as.matrix(net), mode = y), mode = z)
data$weight = igraph::degree(igraph_graph_adjacency_matrix(as.matrix(net), mode = y), mode = z)

} else {
data$weight = sna::degree(net, gmode = is_dir, cmode = ifelse(x == "degree", "freeman", x))
Expand Down Expand Up @@ -736,3 +736,12 @@ ggnet <- function(
return(p)

}


igraph_graph_adjacency_matrix <- function(...) {
if (packageVersion("igraph") >= "2.0.0") {
igraph::graph_from_adjacency_matrix(...)
} else {
igraph::graph.adjacency(...)
}
}
2 changes: 1 addition & 1 deletion R/ggnet2.R
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ ggnet2 <- function(

y = ifelse(is_dir == "digraph", "directed", "undirected")
z = c("indegree" = "in", "outdegree" = "out", "degree" = "all", "freeman" = "all")[x]
data$size = igraph::degree(igraph::graph.adjacency(as.matrix(net), mode = y), mode = z)
data$size = igraph::degree(igraph_graph_adjacency_matrix(as.matrix(net), mode = y), mode = z)

} else {
data$size = sna::degree(net, gmode = is_dir, cmode = ifelse(x == "degree", "freeman", x))
Expand Down
2 changes: 1 addition & 1 deletion R/ggpairs_internal_plots.R
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ wrap_fn_with_param_arg <- function(
allParams$mapping <- mapping
argsList <- list(...)
allParams[names(argsList)] <- argsList
do.call(original_fn, allParams)
rlang::inject(original_fn(!!!allParams))
}

class(ret_fn) <- "ggmatrix_fn_with_params"
Expand Down

0 comments on commit b062ddf

Please sign in to comment.