Skip to content

Commit

Permalink
Make all data numeric in grid plots, reduce point size and slightly c…
Browse files Browse the repository at this point in the history
…hange neutral color scheme
  • Loading branch information
thomvolker committed May 30, 2024
1 parent 092795e commit b385bcd
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions R/plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -355,12 +355,10 @@ create_bivariate_plot <- function(data, ext, vars, logscale, show.sample){

plot <-
ggplot2::ggplot(data, mapping = ggplot2::aes(x = .data[[vars[1]]], y = .data[[vars[2]]])) +
ggplot2::geom_point(ggplot2::aes(colour = ext$dr, shape = show.sample),
alpha = 1,
size = 2.0) +
ggplot2::geom_point(ggplot2::aes(colour = ext$dr, shape = show.sample)) +
ggplot2::scale_colour_gradient2(low = "#00204DFF",
high = "#7D0000",
mid = "lightyellow",
mid = "navajowhite",
midpoint = 0,
limits = c(dr_min, dr_max)) +
ggplot2::theme_bw() +
Expand Down Expand Up @@ -451,6 +449,10 @@ plot_bivariate <- function(x, vars = NULL, samples = "both", grid = FALSE,

} else {

# Make all variables numeric to include them in a single grid-plot
numvars <- sapply(data, is.numeric)
data[,!numvars] <- sapply(data[,!numvars], \(x) x |> as.factor() |> as.numeric())

ext <- data.frame(data, dr = ext$dr, sample = ext$sample)
datlist <- lapply(var_combinations, \(v) data.frame(values.x = ext[,v[1]],
values.y = ext[,v[2]],
Expand All @@ -469,13 +471,12 @@ plot_bivariate <- function(x, vars = NULL, samples = "both", grid = FALSE,
plot <-
ggplot2::ggplot(plot_data, mapping = ggplot2::aes(x = values.x, y = values.y,
shape = show.sample)) +
ggplot2::geom_point(ggplot2::aes(colour = dr),
size = 2.0) +
ggplot2::geom_point(ggplot2::aes(colour = dr)) +
ggplot2::facet_grid(rows = ggplot2::vars(yvar), cols = ggplot2::vars(xvar), scales = "free",
switch = "both") +
ggplot2::scale_colour_gradient2(low = "#00204DFF",
high = "#7D0000",
mid = "lightyellow",
mid = "navajowhite",
midpoint = 0,
limits = c(dr_min, dr_max)) +
ggplot2::scale_y_continuous(position = "left") +
Expand Down

0 comments on commit b385bcd

Please sign in to comment.