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

Multiple plots does not work (on Windows) for plot() function #157

Open P-Barnabas opened 1 year ago

P-Barnabas commented 1 year ago

When running the code below the multiple plot results in a plot only in the top left position of the multiplot. The plot which is shown in the output is the last plot (I checked for instances of plotting different plots on a multiplot) so it seems that the Racmacs plot function always plots to the first position on a multiplot.

library(Racmacs)

map <- read.acmap(system.file("extdata/h3map2004.ace", package = "Racmacs"))

par(mfrow=c(2,2))
for (i in 1:4){
  plot(map)
}

The heart of the problem is that the Racmacs plotting function resets the position the next plot should be located in for multiple plots to the first position. When the Racmacs plot is used after a standard plotting function it does produce a plot on the next position, however, in the reversed order, the standard plot is put in the top left corner and all other previous plots are erased.

par(mfrow=c(2,2))
plot(map)
plot(1:4,1:4)

(above) Results in the second plot in the top left corner

par(mfrow=c(2,2))
plot(1:4,1:4)
plot(map)

(above) Results in the first plot in the top left and the second (the acmap) in the top right

par(mfrow=c(2,2))
plot(1:4,1:4)
plot(1:4,1:4)
plot(map)
plot(1:4,1:4)

(above) Results in only the last plot displayed in the top left corner, since the Racmacs plot reset the multiple plots

drserajames commented 1 year ago

A couple of others points