[R] Plot MArginal distribution in the correct place

Jim Lemon drjimlemon at gmail.com
Sun Jun 18 12:47:37 CEST 2017


As you have categorized the original values, they are different from
the originals. You could include the categories like this, with a bit
of fiddling the margins and y limits for the right hand plot:

x11(width=10)
nf<-layout(matrix(c(1,1,1,1,2,2),1,6,byrow=TRUE))
par(mar=c(10,6,6,6))
matplot(Simulation,type="l",ylim=c(0,40000))
abline(h = 8000, lwd = 2, col = "black")
abline(h = 12000, lwd = 2, col = "black")
title("Dinamic Montecarlo Simulation 2 years ahead",font=4)
fhist<-hist(Simulation,plot=FALSE)
par(mar=c(10,6,6,6))
barplot(fhist$counts,axes=FALSE, space=0,horiz=TRUE,col="lightgray",
 names.arg=paste(fhist$breaks[1:23],fhist$breaks[2:24],sep="-"),
 las=2,ylim=c(-3,40))
grid()
title("Marginal Distribution",font=4)

Jim



On Sun, Jun 18, 2017 at 3:51 AM, Pedro páramo <percentil101 at gmail.com> wrote:
> Can you suggest a plot on the right side so that the right plot has the same
> units of left plot and reflect the counts of the number of time the values
> repeat, something like the empirical distribution?
>



More information about the R-help mailing list