Hi Theresa,
and Welcome to the IsoriX user group,
I will use an example from the package since not everyone has access to the book.
Let us start by creating similar data to those you want to plot:
library(IsoriX)
GNIPDataDEagg <- prepsources(data = GNIPDataDE)
GermanFit <- isofit(data = GNIPDataDEagg, mean_model_fix = list(elev = TRUE, lat_abs = TRUE))
GermanScape <- isoscape(raster = ElevRasterDE, isofit = GermanFit)
CalibAlien <- calibfit(data = CalibDataAlien, isofit = GermanFit)
AssignmentDry <- isofind(data = AssignDataAlien, isoscape = GermanScape, calibfit = CalibAlien)
Before plotting we may want to determine who is likely to be a migrant and who is not.
This could be done as follows:
pv <- sapply(seq_len(nrow(AssignDataAlien)), \(i) extract(AssignmentDry$sample$pv[[i]], cbind(AssignDataAlien$long[i], AssignDataAlien$lat[i])))
migratory_status <- ifelse(pv < 0.05, "status = migrant", "Status = local")
So basically at each position each alien has been found, we extract the pv from the assignment raster and then label the migratory status as "migrant" if pv < 0.05 and label it as "local" otherwise.
Ok now, the default plot showing assignment plots for the first 2 individuals would be obtained as follow:
my_plot <- plot(AssignmentDry, who = 1:2, sources = list(draw = FALSE), calibs = list(draw = FALSE))
Note that I stored the output of the plot as an object called "my_plot", because as we/you want to modify this default plot we will need to reuse it.
To now change the size of the text on the plot, you can simply do that:
update(my_plot, par.settings = list(fontsize = list(text = 20)))
What this does is that it updates the information stored in the plot, which will make the plot being rendered differently.
Technically the information behind a plot are stored as a large list.
Here we updated the element called "par.settings" which is itself a list with an element "fontsize", which is itself a list with the element "text" we want to change.
It is not very intuitive but powerful if you manage to guess what the parameter you want to change is called.
To now which graphical parameters can be changed you can try:
names(lattice::trellis.par.get("par.settings"))
Unfortunately, I fear that the help files describing each items are spread-out across many help files when existing at all.
This is not IsoriX's fault, but that of package IsoriX builds on (lattice).
I was able to guess what to change was called "fontsize", tried and it worked so I got lucky, but sometimes you need a little trial or error (or to google, which I tend not to do).
I guess that deep down to the names used stem from those used in the package "grid" which most graphic packages ultimately rely on.
To update the name on top of the sub-plots, it is the same idea:
update(my_plot, strip = lattice::strip.custom(factor.levels = migratory_status))
Here to guess, I had to look a little as how rasterVis (the package using lattice to plot rasters) works.
But I could also have guessed based on the name.
Note that I used the vector "migratory_status" defined above, but you can of course directly give a vector of character instead.
I think that everything in a lattice plot can be changed using update(), which is quite elegant once you know what the thing you want to change are called.
To get the full view of all that can be changed, just look at the data behind the plot:
str(my_plot)
Of course you can change several things at once, so the answer to your question would be:
update(my_plot,
strip = lattice::strip.custom(factor.levels = migratory_status),
par.settings = list(fontsize = list(text = 20)))
You can alternatively use update() one change at the time and store the result of the update() call into a new object which you reuse:
my_plot2 <- update(my_plot, strip = lattice::strip.custom(factor.levels = migratory_status))
my_plot3 <- update(my_plot, par.settings = list(fontsize = list(text = 20)))
Let me know if that works for you and/or if there is still something hard to grasp... Lattice is not easy (but it is powerful).
++
Alex