RGeostats merge plots

Here you can report the problems encountered with the graphical functions (db.plot, vario.plot, ...)

RGeostats merge plots

Postby Kriegeage_ecologie » Tue Oct 03, 2023 5:09 pm

Hello! I am currently working in the field of ecology and I am aiming at kringing the value of different metallic contaminant with the RGeostats package.

The interpolation functions work well but I have encountered some issues with the graphical representations. Ideally, I would like to merge all my plots into one using the par function of the graphics package, which usually works with base R plot.

In my code, "df" is a dataframe containing the coordinates of my points (attributes "X" and "Y") and the value of Aluminium (attribute "Al") and Zinc (attribute "Zn") contaminants measured at each location.

Code: Select all
```{r, figures-side, fig.show = "hold", out.width = "50%"}
dbAl <- db.create(x1 = as.numeric(df$X),
                 x2 = as.numeric(df$Y),
                 z1 = df$Al,
                 flag.grid = FALSE)

dbZn <- db.create(x1 = as.numeric(df$X),
                 x2 = as.numeric(df$Y),
                 z1 = df$Zn,
                 flag.grid = FALSE)

par(mfrow = c(1, 2))

db.plot(dbAl, title = "Al")
db.plot(dbZn, title = "Zn")
```


When I run this code, the two plots are plotted as two separate graphs and the code returns the error (here, in french):

Code: Select all
la valeur de 'nc' dans "mfg" est mauvaise et sera ignorée


(meaning "the value of 'nc' in "mfg" is wrong and will be ignored", once translated in English)

So I gather that R has some issue with me trying to set nc =2 in my call of par, especially since the error is not longer raised when I modyfy my code to:

Code: Select all
```{r, figures-side, fig.show = "hold", out.width = "50%"}
par(mfrow = c(1, 1))
db.plot(dbAl, title = "Al")
db.plot(dbZn, title = "Zn")
```


(which still print the plots as two separate graphes.)

The setting of the chunk allows the output in the knitted file to show the two graphs side-by-side, which is a way to get around the problem if no other solution exist, and was inspired by the answer to a previous question at:
http://rgeostats.free.fr/forum/viewtopic.php?f=20&t=505

But, if possible, I would really like to be able to direcly edit a single graph in which all my plot are combined.

I am very grateful for any attention you might give this question.
Kriegeage_ecologie
 
Posts: 1
Joined: Tue Oct 03, 2023 3:38 pm

Re: RGeostats merge plots

Postby Didier Renard » Mon Mar 11, 2024 8:23 am

This should be able by using the 'add' argument.
However, please note that merging two graphic representations of a grid using "raster" option does not provide a good answer... as the raster representation covers the whole area and the last statement will cover the first one.
Didier Renard
 
Posts: 337
Joined: Thu Sep 20, 2012 4:22 pm


Return to Graphical representation

Who is online

Users browsing this forum: No registered users and 1 guest