[R] A horizontal or vertical line draw on mosaic plot?

Sang Chul Choi Choi at Biology.Rutgers.Edu
Fri May 2 19:04:52 CEST 2008


Hi,

I want to have a horizontal line on a mosaic plot with "vcd" package.  
This would give me an idea where is 0.5 proportion in a cell. Using  
"mosaicplot" function of "graphics" package, I can draw a line using  
"abline." But, with "mosaic" function of "vcd" package, I have tried  
to use "abline" function, which complains "plot.new has not been  
called yet".

Is there a way to draw lines across a mosaic plot?

========================================================
library(vcd)
music = c(210, 194, 170, 110,
            190, 406, 730, 290)
dim(music) = c(2, 4)
dimnames(music) = list(Age = c("Old", "Young"),
                         Education = c("High", "Low", "Upper", "Lower"))
mosaic(music, keep_aspect_ratio=FALSE)
abline(h=0.5)
Error in int_abline(a = a, b = b, h = h, v = v, untf = untf, ...) :
   plot.new has not been called yet
========================================================

Thank you,

Sang Chul



More information about the R-help mailing list