为什么我的刻度线设置在不在轴上的值位置的值?

时间:2017-01-22 22:07:10

标签: r plot

我制作了一个图表(见下文),并且可以看到刻度线上的值0不会从图表的开头开始。 Tree diagram

enter image description here

    Tree<-as.vector(Site$`2617`$counts[1:183, 8])
RadioCarbon<-Site$`2617`$chronologies$`NAPD 1`$age
Tree

#turn to percentages
x<-(Tree)
M<-max(Tree, na.rm=FALSE)
m<-min (Tree, na.rm = FALSE)
Tree1<-((x-m)*100)/(M-m)


#because we want a straight vertical left border to shade the diagram, 
#we add values (0)
#to before and after the value sequence of x-axis (!)

Tree2<-append(0,Tree1)
Tree2<- append(Tree2, 0)

#we want to add "partners" to the above values and just replicate the 
#first value and last value and modify the NAs
RadioCarbon <-append(RadioCarbon[1],RadioCarbon)
RadioCarbon
t<- tail(RadioCarbon, n=1)
RadioCarbon1<-append(RadioCarbon, t) 
RadioCarbon1<-rev(RadioCarbon1)

#now we plot without labels
RadioCarbon1
plot(Tree2, RadioCarbon1, type="l",  
     xlab = expression('%pollen'~italic('Fagus grandifolia')), 
     yaxt = 'n', xaxt = 'n', ylab= "CalYears BP", 
     main = "Southern NY, Sutherland Pond", labels =FALSE)


#creating x-axis labelling
a <- c(0,25,50,75,100)
axis(1, at = a, labels = a)



#creating y-axis tick marks and labels (choose Values closest to 1000s)


axis(2, at = seq(from = max(RadioCarbon1), to = 0, by = 1000), las=2)
#
ticksCal
ticksCal<- seq(from = 0, to = max(RadioCarbon1), by = 1000)
labelsCal<-as.character(ticksCal)
labelsCal<-rev(labelsCal)
axis(2,  at = ticksCal, labels = labelsCal, las=1)

数据

Tree <-
  c(1, 2, 3, 8, 4, 5, 11, 9, 11, 5, 12, 19, 11, 4, 10, 17, 11, 
    5, 14, 19, 17, 26, 13, 10, 9, 18, 13, 14, 19, 14, 6, 14, 8, 11, 
    6, 15, 2, 22, 2, 13, 17, 13, 6, 24, 11, 13, 15, 12, 38, 22, 3, 
    29, 12, 19, 10, 6, 8, 20, 13, 11, 10, 15, 7, 5, 15, 13, 9, 12, 
    14, 10, 10, 13, 8, 11, 8, 12, 12, 5, 11, 7, 13, 8, 9, 12, 7, 
    8, 12, 9, 12, 19, 19, 17, 8, 8, 25, 26, 16, 20, 16, 30, 26, 3, 
    17, 16, 7, 9, 13, 22, 12, 0, 8, 8, 3, 4, 7, 8, 3, 1, 5, 4, 6, 
    2, 2, 1, 2, 1, 1, 0, 2, 1, 3, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 
    0, 0, 0, 0, 0, 0, 3, 1, 0, 1, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 
    0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0)

RadioCarbon <-
  c(44, 89, 133, 178, 258, 373, 489, 604, 720, 836, 951, 1067, 
    1182, 1298, 1413, 1529, 1644, 1760, 1876, 1991, 2036, 2069, 2102, 
    2134, 2167, 2200, 2232, 2265, 2297, 2330, 2363, 2395, 2428, 2460, 
    2493, 2526, 2558, 2591, 2624, 2673, 2738, 2803, 2869, 2934, 3000, 
    3065, 3130, 3196, 3261, 3326, 3392, 3457, 3522, 3588, 3653, 3718, 
    3784, 3849, 3915, 3980, 4014, 4047, 4080, 4114, 4148, 4181, 4214, 
    4248, 4282, 4315, 4348, 4382, 4416, 4449, 4482, 4516, 4550, 4583, 
    4616, 4650, 4712, 4774, 4836, 4898, 4960, 5022, 5084, 5146, 5208, 
    5270, 5333, 5395, 5457, 5519, 5581, 5643, 5705, 5767, 5829, 5913, 
    6020, 6127, 6233, 6340, 6447, 6553, 6660, 6767, 6873, 6980, 7087, 
    7193, 7300, 7407, 7513, 7620, 7727, 7833, 7940, 8047, 8153, 8260, 
    8367, 8473, 8580, 8687, 8793, 8900, 9007, 9113, 9220, 9327, 9433, 
    9540, 9566, 9591, 9617, 9630, 9793, 9957, 10120, 10274, 10429, 
    10583, 10737, 10891, 11046, 11200, 11375, 11550, 11725, 11900, 
    12075, 12250, 12425, 12600, 12775, 12950, 13125, 13475, 13825, 
    14525, 15225, 15925, 16625, 17325, 18025, 18725, 19425, 20125, 
    20825, 21525, 22225, 22925, 23625, 24325, 25025, 25725, 26425, 
    27125, 27825, 28525, 29225)

现在RadioCarbon以44结束。那么为什么0的值不是最后一个滴答?我也尝试使用0作为最后一个值,但它也没有用。我最终应该从44岁开始吗?但是,我怎样才能在每个偶数(倍数)千位数处生成均匀间距?

谢谢!

1 个答案:

答案 0 :(得分:0)

您的数据最多可达29225,但您的比例仅为29000.由于此反转,29000标签最终位于0轴位置,0标签最终位于29000位置。最快的&amp;最简单的解决方案就是调整您的标签位置,例如

axis(2,  at = ticksCal + 225, labels = labelsCal, las=1)

所以,这会将标签向上移动超过29000的超过大小,即225点