0

I am trying to design a fairly customized plot in R.

One thing I want to do is add tick marks that are different from the labels - that is, only every 5th tick mark will be labeled. I didn't see an easy way to do this, so I did this:

plot(x = Freq_, y = Mean_ipsi, 
     pch = 20,
     ylim = c(-0.5, .9),
     col = 1 + (ProbF < .05) + (ProbF < .01),
     xaxt = 'n',
     xlab = "Frequency (MHz)", ylab = "z-in minus z-out",
     main = "Temporal, Engle 1, Epi, subjectwise",
     yaxt = 'n')
mtext(text = seq(1.56, 35.1, by = 1.95),
      side = 1, at = seq(1.56, 35.1, by = 1.95), cex = .5,line = 0.25)
axis(1, at = Freq_, tick = TRUE, labels = NA)

and it worked just as I wanted.

But when I changed some of the code preceding mtext I got unexpected results

plot(x = Freq_, y = Mean_ipsi, 
     pch = 20,
     ylim = c(-0.5, .9),
     col = "red",
     xlab = "Frequency (MHz)", ylab = "z-in minus z-out",
     main = "Temporal, Engle 1, Epi, subjectwise 
     \n p values for difference between ipsi and contra",
     yaxt = 'n', type = 'o')
mtext(text = seq(1.56, 35.1, by = 1.95),
      side = 1, at = seq(1.56, 35.1, by = 1.95),
      cex = .5,line = 0.25)
axis(1, at = Freq_, tick = TRUE, labels = NA)

Now, in addition to the x-axis being labeled with every numbers 1.56, 3.51, etc. I get large numbers (cex = 1, I think) at 5, 10 and so on. I don't want these.

I have no idea what is happening here.

Peter Flom
  • 2,008
  • 4
  • 22
  • 35

1 Answers1

4

You're missing xaxt="n" in your second version.

Freq_ <- seq(1.56, 35.1, by = 1.95)
Mean_ipsi <- (0.01 * Freq_)
ProbF <- 0.0

#First Version  
plot(x = Freq_, y = Mean_ipsi, 
     pch = 20,
     ylim = c(-0.5, .9),
     col = 1 + (ProbF < .05) + (ProbF < .01),
     xaxt = 'n',
     xlab = "Frequency (MHz)", ylab = "z-in minus z-out",
     main = "Temporal, Engle 1, Epi, subjectwise",
     yaxt = 'n')
mtext(text = seq(1.56, 35.1, by = 1.95),
      side = 1, at = seq(1.56, 35.1, by = 1.95), cex = .5,line = 0.25)
axis(1, at = Freq_, tick = TRUE, labels = NA)

#=============================================

#Second Version
plot(x = Freq_, y = Mean_ipsi, 
     pch = 20,
     ylim = c(-0.5, .9),
     col = "red",
     xlab = "Frequency (MHz)", ylab = "z-in minus z-out",
     main = "Temporal, Engle 1, Epi, subjectwise 
     \n p values for difference between ipsi and contra",
     yaxt = 'n', type = 'o')  ##### <----- add xaxt="n" here #####
mtext(text = seq(1.56, 35.1, by = 1.95),
      side = 1, at = seq(1.56, 35.1, by = 1.95),
      cex = .5,line = 0.25)
axis(1, at = Freq_, tick = TRUE, labels = NA)
bill_080
  • 4,692
  • 1
  • 23
  • 30