0

我正在尝试在 R 中设计一个相当定制的情节。

我想做的一件事是添加与标签不同的刻度线 - 也就是说,只有每 5 个刻度线才会被标记。我没有看到一个简单的方法来做到这一点,所以我这样做了:

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)

它就像我想要的那样工作。

但是当我更改 mtext 之前的一些代码时,我得到了意想不到的结果

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)

现在,除了用每个数字 1.56、3.51 等标记的 x 轴之外,我在 5、10 等处得​​到大数字(我认为 cex = 1)。我不要这些。

我不知道这里发生了什么。

4

1 回答 1

4

xaxt="n"在第二个版本中丢失了。

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)
于 2012-12-08T01:06:53.223 回答