acorg / Racmacs

Racmacs R package for performing antigenic cartography
https://acorg.github.io/Racmacs/
GNU Affero General Public License v3.0
20 stars 9 forks source link

Odd behaviour of agOutlineWidth with ggplot.acmap #146

Closed drserajames closed 1 year ago

drserajames commented 1 year ago

When I alter agOutlineWidth and plot using ggplot.acmap, its behaviour is very odd. I would expect it to behave like with plot.acmap. When you change one point to have a thicker outline width, that just make the others thinner. It's very weird and it's difficult to make good looking maps.

Racmacs-plot.pdf Racmacs-ggplot.pdf

packageVersion("Racmacs") [1] ‘1.1.38’

packageVersion("Racmacs")
library(ggplot2)

set.seed(123)
dat <- matrix(10*2^round(10*runif(100)), ncol=10)
set.seed(456)
map <- make.acmap(dat, verbose=F, options=list(report_progress = F))

map1 <- map2 <- map3 <- map
agOutlineWidth(map1) <- 1
agOutlineWidth(map2) <- 2
agOutlineWidth(map3) <- 3
map2_1 <- map2
agOutlineWidth(map2_1)[1] <- 1
map2_1_3 <- map2_1_70 <- map2_1
agOutlineWidth(map2_1_3)[3] <- 3
agOutlineWidth(map2_1_70)[3] <- 70

pdf("~/Downloads/Racmacs-plot.pdf", width=8, height=12)
par(mfrow=c(3,2))
plot(map1)
title(main="agOutlineWidth(map1) <- 1")
plot(map2)
title(main = "agOutlineWidth(map2) <- 2")
plot(map3)
title(main = "agOutlineWidth(map3) <- 3")
plot(map2_1)
title(main = "agOutlineWidth(map2_1)[1] <- 1")
plot(map2_1_3)
title(main = "agOutlineWidth(map2_1_3)[3] <- 3")
plot(map2_1_70)
title(main = "agOutlineWidth(map2_1_70)[3] <- 70")
dev.off()    

pdf("~/Downloads/Racmacs-ggplot.pdf", width=8, height=12)
grid.arrange(ggplot(map1) + theme(legend.position="none") + labs(title = "agOutlineWidth(map1) <- 1"),
            ggplot(map2) + theme(legend.position="none") + labs(title = "agOutlineWidth(map2) <- 2"),
            ggplot(map3) + theme(legend.position="none") + labs(title = "agOutlineWidth(map2) <- 3"),
            ggplot(map2_1) + theme(legend.position="none") + labs(title = "agOutlineWidth(map2_1)[1] <- 1"),
            ggplot(map2_1_3) + theme(legend.position="none") + labs(title = "agOutlineWidth(map2_1_3)[3] <- 3"),
            ggplot(map2_1_70) + theme(legend.position="none") + labs(title = "agOutlineWidth(map2_1_70)[3] <- 70"))
dev.off()     
shwilks commented 1 year ago

ah yes, this has to do with linewidth being introduced as a new aesthetic variable into ggplot but is now fixed in the version of Racmacs on my fork at shwilks/Racmacs. I'll try and remember to close this when I push the new version to this repo.

shwilks commented 1 year ago

Now resolved