# data

set.seed(4566)

data <- rnorm(100)

# layout where the boxplot is at top

nf <- layout(mat = matrix(c(1,2),2,1, byrow=TRUE), height = c(1,3))

par(mar=c(3.1, 3.1, 1.1, 2.1))

boxplot(data, horizontal=TRUE, outline=TRUE,ylim=c(-4,4), frame=F, col = "green1")

hist(data,xlim=c(-4,4), col = "pink")

# layout boxplot is at the bottom

nf <- layout(mat = matrix(c(1,2),2,1, byrow=TRUE), height = c(3,1))

par(mar=c(3.1, 3.1, 1.1, 2.1))

hist(data,xlim=c(-4,4), col = "pink")

boxplot(data, horizontal=TRUE, outline=TRUE,ylim=c(-4,4), frame=F, col = "green1", width = 10)

# Added to the plot:

par(mar=c(3.1, 3.1, 1.1, 2.1))

hist(data,xlim=c(-4,4), col = "pink")

boxplot(data, horizontal=TRUE, outline=TRUE, ylim=c(-4,4), frame=F, col = "green1", add = TRUE)

set.seed(4566)

data <- rnorm(100)

# layout where the boxplot is at top

nf <- layout(mat = matrix(c(1,2),2,1, byrow=TRUE), height = c(1,3))

par(mar=c(3.1, 3.1, 1.1, 2.1))

boxplot(data, horizontal=TRUE, outline=TRUE,ylim=c(-4,4), frame=F, col = "green1")

hist(data,xlim=c(-4,4), col = "pink")

# layout boxplot is at the bottom

nf <- layout(mat = matrix(c(1,2),2,1, byrow=TRUE), height = c(3,1))

par(mar=c(3.1, 3.1, 1.1, 2.1))

hist(data,xlim=c(-4,4), col = "pink")

boxplot(data, horizontal=TRUE, outline=TRUE,ylim=c(-4,4), frame=F, col = "green1", width = 10)

# Added to the plot:

par(mar=c(3.1, 3.1, 1.1, 2.1))

hist(data,xlim=c(-4,4), col = "pink")

boxplot(data, horizontal=TRUE, outline=TRUE, ylim=c(-4,4), frame=F, col = "green1", add = TRUE)

## No comments:

## Post a Comment

Note: Only a member of this blog may post a comment.