Skip to content

Commit ccabe99

Browse files
Fixes issue with real-time plotting
1 parent ae0c48f commit ccabe99

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

R/plot.R

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,22 @@
1-
#' @title Plot Progress
1+
#' Plot a \code{bayesOpt} object
22
#'
3-
#' @description
4-
#' This function simply creates 2 stacked ggplots.
3+
#' Returns 2 stacked plots - the top shows the results from FUN at each iteration.
4+
#' The bottom shows the utility from each point before the search took place.
55
#'
66
#' @param x An object of class bayesOpt
7-
#' @param ... unused
7+
#' @param ... Passed to \code{ggarrange()} when plots are stacked.
88
#' @importFrom ggplot2 ggplot aes_string xlab scale_color_discrete geom_point theme guides guide_legend margin element_text unit xlim ylab
99
#' @importFrom ggpubr ggarrange annotate_figure text_grob
1010
#' @importFrom graphics plot
1111
#' @return an object of class ggarrange
1212
#' @export
1313
plot.bayesOpt <- function(x,...) {
1414

15-
# x <- Results
16-
#
17-
# plot(x)
18-
1915
acqN <- getAcqInfo(x$optPars$acq)
16+
scoreSummary <- x$scoreSummary[!is.na(get("Score")),]
2017

2118
# Score Plot
22-
sc <- ggplot(x$scoreSummary,aes_string(x="Epoch",y="Score",color="acqOptimum")) +
19+
sc <- ggplot(scoreSummary,aes_string(x="Epoch",y="Score",color="acqOptimum")) +
2320
geom_point() +
2421
xlab("") +
2522
scale_color_discrete(drop=TRUE,limits=c(TRUE,FALSE)) +
@@ -39,9 +36,9 @@ plot.bayesOpt <- function(x,...) {
3936
)
4037

4138
# Utility Plot
42-
ut <- ggplot(x$scoreSummary[!is.na(get("gpUtility")),],aes_string(x="Epoch",y="gpUtility",color="acqOptimum")) +
39+
ut <- ggplot(scoreSummary[!is.na(get("gpUtility")),],aes_string(x="Epoch",y="gpUtility",color="acqOptimum")) +
4340
geom_point() +
44-
xlim(c(0,max(x$scoreSummary$Epoch))) +
41+
xlim(c(0,max(scoreSummary$Epoch))) +
4542
ylab("Utility") +
4643
scale_color_discrete(drop=TRUE,limits=c(TRUE,FALSE)) +
4744
theme(
@@ -66,11 +63,14 @@ plot.bayesOpt <- function(x,...) {
6663
, ncol=1
6764
, common.legend = TRUE
6865
, legend = "bottom"
66+
, ...
6967
)
7068

71-
annotate_figure(
72-
gga
73-
, top = text_grob(label = "Bayesian Optimization Results")
69+
print(
70+
annotate_figure(
71+
gga
72+
, top = text_grob(label = "Bayesian Optimization Results")
73+
)
7474
)
7575

7676
}

0 commit comments

Comments
 (0)