From 33281f5f9fc332f1300dd6e2687bf897b0e0a6f9 Mon Sep 17 00:00:00 2001 From: William Thompson Date: Mon, 29 Jan 2024 10:02:06 -0800 Subject: [PATCH] Support \pm in scientific notation --- src/PairPlots.jl | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/PairPlots.jl b/src/PairPlots.jl index bc24406..5c4a4e3 100644 --- a/src/PairPlots.jl +++ b/src/PairPlots.jl @@ -214,13 +214,22 @@ function margin_confidence_default_formatter(low,mid,high) use_scientific = digits_after_dot > 4 if use_scientific - title = @sprintf( - "\$(%.1f^{+%.1f}_{-%.1f})\\times 10^{-%d}\$", - mid*10^(digits_after_dot-1), - high*10^(digits_after_dot-1), - low*10^(digits_after_dot-1), - (digits_after_dot-1) - ) + if round(low, digits=digits_after_dot) == round(high, digits=digits_after_dot) + title = @sprintf( + "\$(%.1f \\pm %.1f)\\times 10^{-%d}\$", + mid*10^(digits_after_dot-1), + high*10^(digits_after_dot-1), + (digits_after_dot-1) + ) + else + title = @sprintf( + "\$(%.1f^{+%.1f}_{-%.1f})\\times 10^{-%d}\$", + mid*10^(digits_after_dot-1), + high*10^(digits_after_dot-1), + low*10^(digits_after_dot-1), + (digits_after_dot-1) + ) + end else # '*' format specifier only supported in Julia 1.10+ @static if VERSION >= v"1.10"