0

I'm using the software R to create the plot of some distributions. I have to see what distribution has fat tails compared to the others, then the distributions should be plotted on the same graph. The problem is in the x axes, because if I put in a plot command axes = TRUE and in all other axes = FALSE, the graph will not be realistic ... just distribution in which I put axes = TRUE will be right, the other will plotted on a wrong axis. So you can not figure out who has the fattest tail. How can I fix? In practice should make sure that all the distributions are plotted only on one x axis.

Here is my code:

pdf("DegreeI_DDF_T.pdf")
par(mar=c(4.5,5,1,1))
plot(rankI1700~degreeI_ord1700,log="xy",main="",ylab="",xlab="",type="s",col=1,axes=TRUE,lwd=1.6)
par(new=TRUE)
plot(rankI1400~degreeI_ord1400,log="xy",main="",ylab="",xlab="",type="s",col=2,axes=FALSE,lwd=1.6)
par(new=TRUE)
plot(rankI800~degreeI_ord800,log="xy",main="",ylab="",xlab="",type="s",col=3,axes=FALSE,lwd=1.6)
par(new=TRUE)
plot(rankI50~degreeI_ord50,log="xy",main="",ylab="DDF",xlab="",type="s",lwd=1.6,col=4,axes=FALSE)

#Add legend
add_legend <- function(...) {
  opar <- par(fig=c(0, 1, 0, 1), oma=c(0, 0, 0, 0), 
    mar=c(0, 0, 0, 0), new=TRUE)
  on.exit(par(opar))
  plot(0, 0, type='n', bty='n', xaxt='n', yaxt='n')
  legend(...)
}

add_legend("bottomright", legend=c("t=500", "t=800", "t=1500","t=1585"), pch=20, 
   col=c(4,3,2,1),
   horiz=TRUE, bty='n', cex=1)

dev.off()

Thanks

This code go launch first->

READ_DATA
data<-read.table("df_degree_B0.00_BC0.00_l33.33_day1")
df<-data.frame(time=data$V1,bank=data$V2,indegree_credit=data$V3,indegree_interbank=data$V6)
rm(data)

degreeI1700<-df$indegree_interbank[df$time==1700]
degreeI_ord1700<-sort(degreeI1700[degreeI1700!=0],decreasing=TRUE)
rankI1700<-c(1:length(degreeI_ord1700))

degreeI1400<-df$indegree_interbank[df$time==1400]
degreeI_ord1400<-sort(degreeI1400[degreeI1400!=0],decreasing=TRUE)
rankI1400<-c(1:length(degreeI_ord1400))

degreeI50<-df$indegree_interbank[df$time==50]
degreeI_ord50<-sort(degreeI50[degreeI50!=0],decreasing=TRUE)
rankI50<-c(1:length(degreeI_ord50))

degreeI800<-df$indegree_interbank[df$time==800]
degreeI_ord800<-sort(degreeI800[degreeI800!=0],decreasing=TRUE)
rankI800<-c(1:length(degreeI_ord800))

In comment you can download the database.

Community
  • 1
  • 1
  • It will be much easier to help you if you provide a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). Right now there is no sample input data so we have no idea what your plot looks like. – MrFlick Feb 03 '15 at 19:41
  • You can download from here: [link](http://www.filedropper.com/dfdegreeb000bc000l3333day11) – Giacomo Rosaspina Feb 03 '15 at 20:25
  • Perhaps [this](http://www.statmethods.net/advgraphs/layout.html) can help with including multplots. – r2evans Feb 03 '15 at 20:41
  • I want all the distribution in the same axes – Giacomo Rosaspina Feb 03 '15 at 20:46

1 Answers1

0

Here is one of many possible solutions. Take a peak at the data and choose some reasonable xlim and ylim values. Then use plot(NULL, xlim = c(X_LOWER, X_UPPER), ylim = c(Y_LOWER, Y_UPPER)) to create an empty plot of that region and add each distribution with the lines function.

Ellis Valentiner
  • 2,136
  • 3
  • 25
  • 36