Closed rb643 closed 4 years ago
Hi.
Both these things are possible to achieve with ggseg. Since ggseg is a wrapper for geom_polygon from ggplot2, you can control outline (colour?
) and opacity (alpha
) either by setting them to a single value (outside mapping = aes()
) or using columns in the data to these instead (from within mapping = aes()
).
library(ggseg)
#> Loading required package: ggplot2
library(dplyr)
#>
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
test_data <- dk %>%
slice(1:4) %>%
select(region, hemi) %>%
mutate(tvalue = c(0.5, 2.5, 6.0, 1.0),
sig = ifelse(tvalue > 2.3, "sig", NA),
sig_a = ifelse(tvalue > 2.3, 1, .5))
test_data
#> # A tibble: 4 x 5
#> region hemi tvalue sig sig_a
#> <chr> <chr> <dbl> <chr> <dbl>
#> 1 superior temporal left 0.5 <NA> 0.5
#> 2 pre central left 2.5 sig 1
#> 3 post central left 6 sig 1
#> 4 rostral middle frontal left 1 <NA> 0.5
ggseg(.data = test_data, atlas = dk,
mapping = aes(fill = tvalue,
colour = sig),
size = 1) +
scale_color_discrete(na.value = "transparent")
ggseg(.data = test_data, atlas = dk,
mapping = aes(fill = tvalue,
alpha = sig_a)) +
scale_alpha_identity()
Created on 2020-03-18 by the reprex package (v0.3.0)
Great! Thanks for the quick response!
Perhaps not an issue more a suggestion for an add-on:
Would it be possible to overlay multiple maps? 1.For example say I have a map of beta values for a given analysis that I plot with high transparency and then overlay a thresholded version of the map highlighting the significant regions?