Skip to content

Commit

Permalink
fix geom_point, add labels, add test
Browse files Browse the repository at this point in the history
  • Loading branch information
simon-smart88 committed Oct 2, 2024
1 parent 0e0dcc4 commit d9e31a6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions R/plotting.R
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,13 @@ plot.disag_model <- function(x, include_iid = FALSE, ...){
geom_abline(intercept = 0, slope = 1, color = 'blue') +
scale_color_manual(values = c("Without IID" = "black")) +
ggtitle(title) +
labs(color = NULL) +
labs(x = "Observed", y = "Predicted", color = NULL) +
theme(legend.position.inside = c(0, 1),
legend.justification = c(0, 1))
if (include_iid){
obspred$scales$scales <- list()
obspred <- obspred +
geom_point(data, aes(x = obs, y = pred, color = "With IID")) +
geom_point(data = data, aes(x = obs, y = pred, color = "With IID")) +
scale_color_manual(values = c("Without IID" = "black", "With IID" = "red"))
}
} else {
Expand Down
4 changes: 4 additions & 0 deletions tests/testthat/test-plotting.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,16 @@ test_that("Check plot.disag_model function works as expected", {

p2 <- plot(fit_result_nofield)

p3 <- plot(result, include_iid = TRUE)

expect_is(p1, 'list')
expect_equal(length(p1), 2)

expect_is(p2, 'list')
expect_equal(length(p2), 2)

expect_is(p3, 'list')
expect_equal(length(p3), 2)

})

Expand Down

0 comments on commit d9e31a6

Please sign in to comment.