Skip to content

Commit fa9fbe9

Browse files
committed
Better legend placement
1 parent 11b3256 commit fa9fbe9

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

R/plot.rd_multi.R

+3-3
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ plot.rd_multi <- function(x, verbose = TRUE, ...) {
127127
colnames(species_markcorr_all)[1] <- c("Reference_mark_species")
128128
colnames(species_markcorr_all)[length(species_markcorr_all)] <- c("r")
129129

130-
graphics::par(mfrow = c(2, 2))
130+
graphics::par(mfrow = c(2, 2), mar = c(4.0, 4.0, 1.5, 0.5)) # bltr
131131

132132
# plot Kest
133133
graphics::plot(NULL, xlim = range(r), ylim = range(c(k_func_all$Reference,
@@ -139,7 +139,7 @@ plot.rd_multi <- function(x, verbose = TRUE, ...) {
139139
graphics::abline(v = rmax, lty = "dotted", col = "grey")
140140

141141
graphics::legend(x = "topleft", legend = c("Reference", "Reconstructed"),
142-
lty = c(2, 1), inset = 0.015)
142+
lty = c(2, 1), bty = "n", cex = 0.8, ncol = 2)
143143

144144
# plot pcf
145145
graphics::plot(NULL, xlim = range(r), ylim = range(c(pcf_func_all$Reference,
@@ -171,7 +171,7 @@ plot.rd_multi <- function(x, verbose = TRUE, ...) {
171171
graphics::lines(x = species_markcorr_all$r, y = species_markcorr_all$species_markcorr_func_recon_mean)
172172
graphics::abline(v = rmax, lty = "dotted", col = "grey")
173173

174-
graphics::par(mfrow = c(1, 1))
174+
graphics::par(mfrow = c(1, 1), c(5.1, 4.1, 4.1, 2.1))
175175

176176
invisible()
177177

vignettes/articles/reconstruct_multi_patterns.Rmd

+5-8
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ library(shar)
2323
library(spatstat)
2424
```
2525

26-
> Please note that the maximum number of iterations has been set to `max_steps = 10000` and `n_repetitions = 1`/`n_repetitions = 3` to keep computational time low for this example. For real-world applications, it is advisable to raise these values. Additionally, we set `verbose = FALSE` in the vignette to minimize printed output. We recommend using the default setting `verbose = TRUE` when executing the code to view progress reports.
26+
> Please note that the maximum number of iterations has been set to `max_steps = 10000` and `n_repetitions = 1`/`n_repetitions = 3` to keep computational time low for this example. For real-world applications, it is advisable to raise these values.
2727
2828
The next step is to load the point pattern, here is an example of a random point pattern with several marks to show the structure of the data used.
2929

@@ -42,25 +42,22 @@ marked_pattern <- as.ppp(random, W = owin(c(0, xr), c(0, yr)))
4242
The point pattern must contain the following data An x and y coordinate, a metric mark (in metres) and a nominal mark defined as a factor. The order must be respected. Now the reconstruction with several marks can be started with the following code. Note that the maximum number of iterations has been set to max_steps = 10000 to keep the computation time for this example to a minimum. For an application, this value should be increased according to the number of points in the pattern.
4343

4444
```{r}
45-
reconstruction <- reconstruct_pattern_multi(marked_pattern, n_repetitions = 1, max_steps = 10000,
46-
verbose = FALSE)
45+
reconstruction <- reconstruct_pattern_multi(marked_pattern, n_repetitions = 1, max_steps = 10000)
4746
```
4847

4948
As a result, you will receive a list containing a variety of information, for example, the reference pattern, the reconstructed pattern, the number of successful actions, the energy development and much more. If you wish to perform several reconstructions of the same reference pattern, you must increase n_repetitions to the desired number.
5049

5150
```{r}
52-
reconstruction_2 <- reconstruct_pattern_multi(marked_pattern, n_repetitions = 3, max_steps = 10000,
53-
verbose = FALSE)
51+
reconstruction_2 <- reconstruct_pattern_multi(marked_pattern, n_repetitions = 3, max_steps = 10000)
5452
```
5553

5654
To activate a visualisation of the reconstruction that shows the changes in the pattern at the relevant time, you must proceed as follows.
5755

5856
```{r}
59-
reconstruction_3 <- reconstruct_pattern_multi(marked_pattern, n_repetitions = 1, max_steps = 10000, plot = TRUE,
60-
verbose = FALSE)
57+
reconstruction_3 <- reconstruct_pattern_multi(marked_pattern, n_repetitions = 1, max_steps = 10000, plot = TRUE)
6158
```
6259

63-
Finally, you can use the following function to view different summary statistics of the reference pattern (black line) compared to the reconstructed pattern (grey line). For this, however, the listed libraries must be loaded additionally.
60+
Finally, you can use the `plot()` function to view different summary statistics of the reference pattern (dashed line) compared to the reconstructed pattern (solid line).
6461

6562
```{r}
6663
plot(reconstruction)

0 commit comments

Comments
 (0)