diff options
Diffstat (limited to 'R')
-rw-r--r-- | R/plot.mkinfit.R | 11 | ||||
-rw-r--r-- | R/plot.mmkin.R | 12 |
2 files changed, 19 insertions, 4 deletions
diff --git a/R/plot.mkinfit.R b/R/plot.mkinfit.R index 3df6c81c..b42ce097 100644 --- a/R/plot.mkinfit.R +++ b/R/plot.mkinfit.R @@ -172,8 +172,15 @@ plot.mkinfit <- function(x, fit = x, } } - chi2 <- paste0(signif(100 * mkinerrmin(fit)[errmin_var, "err.min"], errmin_digits), "%") - mtext(bquote(chi^2 ~ "error level" == .(chi2)), cex = 0.7, line = 0.4) + chi2 <- signif(100 * mkinerrmin(fit)[errmin_var, "err.min"], errmin_digits) + # Use LateX if the current plotting device is tikz + if (names(dev.cur()) == "tikz output") { + chi2_text <- paste0("$\\chi^2$ error level = ", chi2, "\\%") + } else { + chi2_perc <- paste0(chi2, "%") + chi2_text <- bquote(chi^2 ~ "error level" == .(chi2_perc)) + } + mtext(chi2_text, cex = 0.7, line = 0.4) } # Show residuals if requested diff --git a/R/plot.mmkin.R b/R/plot.mmkin.R index 562bbb71..ee7075d3 100644 --- a/R/plot.mmkin.R +++ b/R/plot.mmkin.R @@ -79,8 +79,16 @@ plot.mmkin <- function(x, main = "auto", legends = 1, errmin_var = "All data", e datasets = colnames(x)[i.fit], none = "") - chi2 <- paste0(signif(100 * mkinerrmin(fit)[errmin_var, "err.min"], errmin_digits), "%") - mtext(bquote(.(fit_name) ~ chi^2 ~ "error level" == .(chi2)), cex = cex, line = 0.4) + chi2 <- signif(100 * mkinerrmin(fit)[errmin_var, "err.min"], errmin_digits) + + # Use LateX if the current plotting device is tikz + if (names(dev.cur()) == "tikz output") { + chi2_text <- paste0(fit_name, " $\\chi^2$ error level = ", chi2, "\\%") + } else { + chi2_perc <- paste0(chi2, "%") + chi2_text <- bquote(.(fit_name) ~ chi^2 ~ "error level" == .(chi2_perc)) + } + mtext(chi2_text, cex = cex, line = 0.4) mkinresplot(fit, legend = FALSE, ...) mtext(paste(fit_name, "residuals"), cex = cex, line = 0.4) |