I made this graph to demonstrate the progress being made by an optimization algorithm (https://rstudio-pubs-static.s3.amazonaws.com/132872_620c10f340f348b88453d75ec99960ff.html):
library(GA)
data("eurodist", package = "datasets")
D <- as.matrix(eurodist)
tourLength <- function(tour, distMatrix) {
tour <- c(tour, tour[1])
route <- embed(tour, 2)[,2:1]
sum(distMatrix[route])
}
#Firness function to be maximized
tspFitness <- function(tour, ...) 1/tourLength(tour, ...)
GA <- ga(type = "permutation", fitness = tspFitness, distMatrix = D,
min = 1, max = attr(eurodist, "Size"), popSize = 50, maxiter = 5000,
run = 500, pmutation = 0.2)
plot(GA)
- The "legend" seems to be obscuring the graph – is it somehow possible to hide the legend?
Normally, graphs that are made using Base R and GGPLOT2 libraries can have their legends disabled pretty easily – but since the graphing function being used here is from a different library, I am not sure if it is possible to disable this legend.
Thank you!
>Solution :
This should work:
plot(GA, legend = FALSE)
P.S, if you are not familiar with a package function I always find it helpful to look up the R-documentation in the console using ??GA::plot
