Full numbers in Boxplot

#1
Hi all,

I have a problem: I only want to have the full numbers between 1 and 4 in my X axis. However, R always outputs the half steps. What do I have to do to make them disappear?

Many thanks, Tom

boxplot with decimals.JPG
Code:
# ~ Illustrating causal estimates for causal models ~ ~ ~ ~ ~

add_estimate2 <- function(model, xpos) {
  # Estimate for causal effect
  estimate2 <- model$coefficients['dat$ZSpAttAnx_Emp']
  # 95 % CI
  ci2 <- confint(model)['dat$ZSpAttAnx_Emp',]
  
  # Draw CI in plot
  arrows(x0 = xpos, x1 = xpos, y0 = ci2[1], y1 = ci2[2], 
         length = 0.05, angle = 90, code = 3)
  # Draw point
  points(xpos, estimate2, pch = 16, bg = 'grey')
}

# Make plot
plot(0, xlim = c(1, 4), ylim = c(0.45, 0.55), pch = '', xlab = 'Model', 
     ylab = 'Causal estimate', main=" quality of prediction models 
     \n burnout employees",)
# Add line at direct causal effect
lines(c(0, 4), c(0.5, 0.5), lty = 5, col = 'red')
# Add a legend
legend(2, 0.54, legend=c("1 direct", "2 total", "3 mod1", "4 mod2"),
        cex=0.8)


# Use function to add data points and error bars (95 % CIs)
add_estimate2(direct, 1)
add_estimate2(total, 2)
add_estimate2(mod1, 3)
add_estimate2(mod2, 4)
 

Dason

Ambassador to the humans
#2
In your plot statement you can use xaxt="n" to suppress the plotting of the xaxis. Then you can use the axis command to directly specify where you want the ticks to show up. Here is an example

Code:
set.seed(42)
x <- rnorm(1000, 100, 15)
y <- 50 + x/2 + rnorm(1000, 0, 1)

plot(x, y, xaxt = "n")
axis(1, at = seq(50, 150, by = 25))