From e763078670b40a7b9f40c53b3d05271e878f0bfc Mon Sep 17 00:00:00 2001
From: Sebastian Henz <sebastian.henz@ufz.de>
Date: Tue, 25 Feb 2020 15:57:05 +0100
Subject: [PATCH] Resolve line thickness weirdness, closes #7

---
 .gitignore      |  1 +
 R/plot_effect.R | 13 +++++++++----
 R/plot_stress.R | 12 ++++++++----
 3 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/.gitignore b/.gitignore
index 065f561..eddaf3d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,3 +4,4 @@
 .Ruserdata
 
 Notizen.md
+*.png
diff --git a/R/plot_effect.R b/R/plot_effect.R
index b3d19c8..061a3ae 100644
--- a/R/plot_effect.R
+++ b/R/plot_effect.R
@@ -52,8 +52,8 @@ plot_effect <- function(model,
         xlab = xlab,
         ylab = ylab,
         xaxt = "n",
-        bty = "L",
-        las = 1
+        las = 1,
+        bty = "L"
     )
 
     points(
@@ -129,8 +129,13 @@ plot_effect <- function(model,
         }
     }
 
-    axis(1, at = log_ticks$major, labels = log_ticks$major_labels)
-    axis(1, at = log_ticks$minor, labels = FALSE, tcl = -0.25)
+    # The setting of col = NA and col.ticks = par("fg") is to prevent ugly line
+    # thickness issues when plotting as a png with type = "cairo" and at a low
+    # resolution.
+    axis(1, at = log_ticks$major, labels = log_ticks$major_labels,
+         col = NA, col.ticks = par("fg"))
+    axis(1, at = log_ticks$minor, labels = FALSE, tcl = -0.25,
+         col = NA, col.ticks = par("fg"))
     plotrix::axis.break(1, breakpos = temp$axis_break_conc)
 
     if (show_legend) {
diff --git a/R/plot_stress.R b/R/plot_stress.R
index c48c978..5f41dbb 100644
--- a/R/plot_stress.R
+++ b/R/plot_stress.R
@@ -36,7 +36,6 @@ plot_stress <- function(model,
 
     temp <- adjust_smooth_concentrations(model)
     curves <- temp$curves
-    axis_break_conc <- temp$axis_break_conc
     log_ticks <- get_log_ticks(curves$concentration)
     concentration <- c(curves$concentration[1], model$args$concentration[-1])
 
@@ -138,9 +137,14 @@ plot_stress <- function(model,
         }
     }
 
-    axis(1, at = log_ticks$major, labels = log_ticks$major_labels)
-    axis(1, at = log_ticks$minor, labels = FALSE, tcl = -0.25)
-    plotrix::axis.break(1, breakpos = axis_break_conc)
+    # The setting of col = NA and col.ticks = par("fg") is to prevent ugly line
+    # thickness issues when plotting as a png with type = "cairo" and at a low
+    # resolution.
+    axis(1, at = log_ticks$major, labels = log_ticks$major_labels,
+         col = NA, col.ticks = par("fg"))
+    axis(1, at = log_ticks$minor, labels = FALSE, tcl = -0.25,
+         col = NA, col.ticks = par("fg"))
+    plotrix::axis.break(1, breakpos = temp$axis_break_conc)
 
     if (show_legend) {
         legend_df <- legend_df[order(legend_df$order), ]
-- 
GitLab