This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Check https://www.zachburchill.ml/constant_scales/ for a walkthrough. | |
# Note that this code is slightly "better" than the code in the post, since it checks | |
# to see if the scales being supplied and used are all continuous. | |
# Examples included after the function definitions. | |
# Given a bunch of plots and a scale you want to apply to them, this returns that scale, | |
# but with limits that encompass the union of all the ranges of values in those plots | |
# Meant to be for users | |
get_shared_scale <- function(..., scale) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# an updated version of https://pastebin.com/0BRwUzpu by SO user mo-seph (https://stackoverflow.com/a/14692588/4560765) | |
# The version above no longer works | |
#' # The example: | |
#' points <- data.frame( x=runif(10), y=runif(10),class=1:10, size=runif(10,min=1000,max=100000) ) | |
#' trans <- data.frame( from=rep(1:10,times=10), to=rep(1:10,each=10), amount=runif(100)^3 ) | |
#' trans <- merge( trans, points, by.x="from", by.y="class" ) | |
#' trans <- merge( trans, points, by.x="to", by.y="class", suffixes=c(".to",".from") ) | |
#' ggplot( points, aes( x=x, y=y ) ) + geom_point(aes(size=size),color="red",shape=1) + | |
#' scale_size_continuous(range=c(4,20)) + |
OlderNewer