2011-10-18 21 views

回答

2

只需基本功能:

plot(x, y, log="xy") 

這將繪製在對數刻度您的觀點。

1

隨着latticelatticeExtra

library(lattice) 
library(latticeExtra) 
xyplot((1:200)/20 ~ (1:200)/20, type = c('p', 'g'), 
     scales = list(x = list(log = 10), y = list(log = 10)), 
     xscale.components=xscale.components.log10ticks, 
     yscale.components=yscale.components.log10ticks) 

更多實例here

1

你已經通過獲得單詞的頻率和等級來努力工作。你只需要在日誌範圍內繪製它們。

##Word frequencies in Moby dick 
dd = read.csv("http://tuvalu.santafe.edu/~aaronc/powerlaws/data/words.txt") 

##Rename the columns and add in the rank 
colnames(dd) = "freq" 
dd$rank = 1:nrow(dd) 

##Plot using base graphics 
plot(dd$rank, dd$freq, log="xy") 

或者你可以使用ggplot2

require(ggplot2) 
ggplot(data=dd, aes(x=rank, y=Freq)) + 
    geom_point() + scale_x_log10() + 
    scale_y_log10()