2013-07-26 50 views

回答

2

當您在函數plot()中使用時,只有對象hist.a$count在x軸上,您將得到與您的對象的長度相對應的數字 - 它們不是a值的實際數字。您可以稍後使用axis()添加實際值,並從hist.a$mids開始添加labels=

set.seed(5555) 
a <- rlnorm(1000) 
hist.a <- hist(a, plot = FALSE) 

hist.a 
    $breaks 
    [1] 0 5 10 15 20 25 30 35 40 

    $counts 
    [1] 955 34 6 2 2 0 0 1 

    $density 
    [1] 0.1910 0.0068 0.0012 0.0004 0.0004 0.0000 0.0000 0.0002 

    $mids 
    [1] 2.5 7.5 12.5 17.5 22.5 27.5 32.5 37.5 

    $xname 
    [1] "a" 

    $equidist 
    [1] TRUE 

    attr(,"class") 
    [1] "histogram" 

plot(hist.a$count, log = "xy",xaxt="n",type="h",lwd=10,lend=2) 
axis(1,at=1:length(hist.a$mids),labels=hist.a$mids)