leaf and stem diagram incompatible with the layout function

56 Views Asked by At

I am trying to join 4 graphs with the layout function. However, I only get 3 represented: all except the stem and leaf diagram.

In brief, this is what it looks like in r:

layout(matrix(c(1,2,3,4), 2, 2, byrow =TRUE))
stem(graph1)
boxplot(graph2)
hist(graph3)
barplot(graph4)

Why doesn't the stem graph plot the same as the others, and is there another function that can do it?

Thank you in advance

1

There are 1 best solutions below

1
On

As @DaveArmstrong already hinted, stem outputs characters, which are printable but not plotable.

You could redirect the output from stem to a plot like so (shamelessly stolen from this SO answer):

layout(matrix(c(1,2,3,4), 2, 2, byrow =TRUE))
## start stem-plot
plot.new()
tmp <- capture.output(stem(c(10,11,20:23)))
text( 0,1, paste(tmp, collapse='\n'), adj=c(0,1), family='mono' )
## end stem-plot
boxplot(runif(100))
hist(rnorm(100))
barplot(1:3)