2

I am trying to add text to individual tiles within a mosaicplot built using the base R function. However, I cant determine the coordinates of each center tile.

And no, I need to limit it to the mosaicplot function and don't want to use the vcd package. The code below demonstrates the addition of text based on the knowledge of where it should go. How can I derive these coordinates?

require(stats) 
attach(Titanic)
mosaicplot(~  Sex + Survived, data = Titanic) 
text( .4,.6, "where to get this number ?",col = "red", cex = 2) 
text( .4,.1, "and how to find coordinates ?",col = "blue", cex = 1.5)
pmanDS
  • 193
  • 1
  • 2
  • 10
  • 1
    This was exactly one of the motivations for writing `vcd`. This computation is quite cumbersome, specifically if more than two variables are involved. Hence, my best recommendation is to reconsider using `vcd`. Or otherwise obtain the source code of `mosaicplot()` and hack your labels into that. – Achim Zeileis Feb 09 '18 at 20:09
  • Thanks Achim, I have now adapted vcd. – pmanDS Feb 15 '18 at 00:27

0 Answers0