Skip to content

Commit

Permalink
Updated readme, plot axis, and news
Browse files Browse the repository at this point in the history
  • Loading branch information
bertcarnell committed Aug 2, 2024
1 parent 300efbc commit d6a5655
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 7 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# version 0.2.0 (2024-07-30)

- bug report from @ghobro (https://github.com/ghobro) for weighted models
- improved x-axis scales

# version 0.1.4 (2024-01-18)

Expand Down
25 changes: 18 additions & 7 deletions R/plot_tornado_plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,21 @@ plot.tornado_plot <- function(x, plot=TRUE, nvar=NA, xlabel="Model Response",
warning("geom_point_control fill argument was added")
}

is_percentage <- FALSE
if (is.data.frame(x$data$factordat))
{
pretty_break <- pretty(c(x$data$plotdat$value, x$data$factordat$value), n = 5)
pretty_break <- pretty(c(x$data$plotdat$value + c(x$data$pmeans), x$data$factordat$value + c(x$data$pmeans)), n = 5) - c(x$data$pmeans)
if (all(c(x$data$plotdat$value + c(x$data$pmeans), x$data$factordat$value + c(x$data$pmeans)) >= 0) &&
all(c(x$data$plotdat$value + c(x$data$pmeans), x$data$factordat$value + c(x$data$pmeans)) <= 1)) {
is_percentage <- TRUE
}
} else
{
pretty_break <- pretty(x$data$plotdat$value, n = 5)
pretty_break <- pretty(x$data$plotdat$value + c(x$data$pmeans), n = 5) - c(x$data$pmeans)
if (all(c(x$data$plotdat$value + c(x$data$pmeans)) >= 0) &&
all(c(x$data$plotdat$value + c(x$data$pmeans)) <= 1)) {
is_percentage <- TRUE
}
}

ggp <- ggplot(x$data$plotdat, aes(x = .data$variable, y = .data$value, fill = .data$Level)) +
Expand All @@ -65,7 +74,8 @@ plot.tornado_plot <- function(x, plot=TRUE, nvar=NA, xlabel="Model Response",
ylab(xlabel) +
xlab("") +
scale_fill_manual(values = sensitivity_colors) +
theme_bw()
theme_bw() +
geom_hline(yintercept = 0, lty = 2)

if (is.data.frame(x$data$factordat))
{
Expand All @@ -74,17 +84,18 @@ plot.tornado_plot <- function(x, plot=TRUE, nvar=NA, xlabel="Model Response",
geom_point_control))
}

if (x$type %in% c("cv.glmnet", "glm") && x$family %in% c("binomial", "quasibinomial"))
if ((x$type %in% c("cv.glmnet", "glm") & x$family %in% c("binomial", "quasibinomial")) | is_percentage)
{
ggp <- ggp +
scale_y_continuous(breaks = pretty_break,
labels = scales::percent(c(pretty_break) + c(x$data$pmeans)),
limits = c(max(min(pretty_break), -x$data$pmeans),
min(max(pretty_break), 1 - x$data$pmeans)))
labels = scales::percent(c(pretty_break) + c(x$data$pmeans)))#,
#limits = c(max(min(pretty_break), -x$data$pmeans),
# min(max(pretty_break), 1 - x$data$pmeans)))
} else
{
ggp <- ggp + scale_y_continuous(breaks = pretty_break,
labels = format(pretty_break + c(x$data$pmeans), digits = 4))

}
if (plot) plot(ggp) else return(ggp)
}
Binary file modified man/figures/censored_coxph_setion-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/censored_section-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/glm_factor_section-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/glm_section-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/random-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified man/figures/train_section-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit d6a5655

Please sign in to comment.