• R/O
  • SSH

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

File Info

Rev. 640ec68822966866be070a2c1ac14f5e4cb65220
大小 4,774 字节
时间 2010-06-02 20:31:33
作者 lorenzo
Log Message

Minor modifications to these codes (either new figures or I am now calculating
probability density functions correctly, even in the case of discrete
distributions).

Content

rm(list=ls())
library(ggplot2)
library(Cairo)
library(tikzDevice)


get_frequence <- function(contact){

freq <- table(contact)

#convert table into a matrix

freq <- matrix(c(as.numeric(names(freq)), freq), ncol=length(freq), byrow=TRUE, dimnames=NULL) 

return (freq)

}


contact_dublin <- read.table("contact_duration_pairwise_many_tags_1_.dat", header=FALSE)

names(contact_dublin) <- c("duration","p_contact")

contact_ht2009 <- read.table("contact_duration_pairwise_many_tags_ht2009.dat", header=FALSE)

names(contact_ht2009) <- c("duration","p_contact")


ml_tmp <- rbind(transform(contact_dublin, set="SG"),
        transform(contact_ht2009, set="HT09")) 


lbls <- levels(ml_tmp$set)

mb <- c(seq(10,100, by=10), seq(200,1e3,by=1e2),seq(2e3,1e4,by=1e3),seq(1e4,2e4,by=1e4))

my_sel <- seq(1,length(mb), by=9)

my_label2 <- rep("",length(mb))
my_label2[my_sel] <- expression(10^1 ,10^2,10^3,10^4)


mb3 <- c(seq(1e-6,1e-5, by=1e-6), seq(2e-5,1e-4,by=1e-5),seq(2e-4,1e-3,by=1e-4),seq(2e-3,1e-2,by=1e-3),
         seq(2e-2,1e-1,by=1e-2),seq(2e-1,1,by=1e-1))

my_sel <- seq(1,length(mb3), by=9)

my_label3 <- rep("",length(mb3))
my_label3[my_sel] <- expression(10^-6 ,10^-5,10^-4,10^-3,10^-2,10^-1,10^0)



gpl <- ggplot(ml_tmp, aes(x=duration, y=p_contact, colour=set, shape=set)) +
    ## geom_vline(xintercept = seq(0,4,by=1), col="white", size=1)+
    ## geom_hline(yintercept = seq(-6,0,by=1), col="white", size=1)+
  geom_point(size=6.5) +
    opts( panel.background=theme_rect(fill='white'))+
#geom_line() +
scale_colour_manual("Data from", breaks=lbls, labels=lbls, values=c(1,2)) +
scale_shape_manual("Data from", breaks=lbls, labels=lbls, values=c(1,2)) +

  #extra stuff
  xlab(expression(paste("Contact Duration (sec)")))+
  ylab(expression(paste("P(contact duration)")))+
   scale_x_continuous(trans="log10", limits=c(10,2e4),breaks=mb,label=my_label2)+
   scale_y_continuous(trans="log10", limits=c(1e-6,1), breaks=mb3,label=my_label3)+  
 # opts(title = expression(paste("HT2009: June, ",30^th)))+
   opts(plot.title = theme_text(size = 40))+
  opts(axis.title.x = theme_text(size = 40))+
  opts(legend.text = theme_text(size = 18, vjust=0.8))+
   opts(legend.title = theme_text(size = 22,hjust=0))+
    opts(panel.grid.minor = theme_blank())+
    opts(axis.ticks = theme_segment(colour = "black", size=0.7),axis.ticks.length = unit(0.3, "cm"))+
opts(panel.grid.major = theme_blank())+
  opts(legend.position = c(0.8, 0.6), legend.background=theme_rect(fill='white')
       ,legend.key = theme_rect(colour = NA))+
  opts(axis.title.y = theme_text(size = 40, angle=90))+
  opts(axis.text.x = theme_text(size=35, colour="black",vjust=1))+
  opts(axis.text.y = theme_text(size=35, colour="black", hjust=1.1))


fn <- paste("Comparison-contact.pdf")




 pdf(fn)
#CairoPDF(fn)
print(gpl)
dev.off()


gpl2 <- ggplot(ml_tmp, aes(x=duration, y=p_contact, colour=set, shape=set)) +
#ggplot(ml_tmp, aes(x=duration, y=p_contact, colour=set, shape=set)) +

  ## geom_vline(xintercept = seq(0,4,by=1), col="white", size=1)+
    ## geom_hline(yintercept = seq(-6,0,by=1), col="white", size=1)+
  geom_point(size=4) +
    geom_point(size=3.8) +
  geom_point(size=3.6) +
    opts( panel.background=theme_rect(fill='white',size=1.5))+
#geom_line() +
## scale_colour_manual("Data from", breaks=lbls, labels=lbls, values=c(1,2)) +
## scale_shape_manual("Data from", breaks=lbls, labels=lbls, values=c(1,2)) +

scale_colour_manual("", breaks=lbls, labels=lbls, values=c(1,2)) +
scale_shape_manual("", breaks=lbls, labels=lbls, values=c(1,2)) +

  #extra stuff
  xlab(expression(paste("$\\Delta t_{ij}$ (sec)")))+
  ylab(expression(paste("$P(\\Delta t_{ij})$")))+
   scale_x_continuous(trans="log10", limits=c(10,2e4),breaks=mb,label=my_label2)+
   scale_y_continuous(trans="log10", limits=c(1e-6,1), breaks=mb3,label=my_label3)+  
 # opts(title = expression(paste("HT2009: June, ",30^th)))+
   opts(plot.title = theme_text(size = 25))+
  opts(axis.title.x = theme_text(size = 20))+
  opts(legend.text = theme_text(size = 14, vjust=0.4))+
   opts(legend.title = theme_text(size = 18,hjust=0))+
    opts(panel.grid.minor = theme_blank())+
    opts(axis.ticks = theme_segment(colour = "black", size=1),axis.ticks.length = unit(0.15, "cm"))+
opts(panel.grid.major = theme_blank())+
  opts(legend.position = c(0.7, 0.8), legend.background=theme_rect(col=0)
       ,legend.key = theme_rect(colour = NA))+
  opts(axis.title.y = theme_text(size = 20, angle=90))+
  opts(axis.text.x = theme_text(size=18, colour="black",vjust=1))+
  opts(axis.text.y = theme_text(size=18, colour="black", hjust=1.1))

  
tikz('Comparison-contact_tik.tex', standAlone = TRUE, width=5,height=5)
print(gpl2)
dev.off() 

tools::texi2dvi('Comparison-contact_tik.tex',pdf=T)





print("So far so good")