4

I am in an intro R class and was wondering how to rotate axis labels on the y axis with mosaic plots (vcd package). They are long labels and right now are completely overlapping each other. I would like to make them perpendicular to the rest of the plot (horizontal rather than vertical). I have tried the the ggplot lingo I am familiar with, las=, and str=, but nothing seems to have an effect.

Here's my existing code:

```{R}
# mosaic plot
library(vcd)
mosaic(~ USfuture + Education, data = OOL.sub, shade=TRUE, legend=TRUE, direction = "v")
```

Thank you!

Katherine
  • 51
  • 1
  • 3

1 Answers1

5

It is unclear to me what you mean by the "y labels", but if you mean the left side labels, then this should do what you request:

mosaic(~ USfuture + Education, data = OOL.sub, shade=TRUE, legend=TRUE, 
   direction = "v", rot_labels=c(0,90,0,0) )

See:

help( labeling_border, pac=vcd)

I had a couple of concerns about your understanding of the particular plotting paradigm being used. For one thing las is a base parameter. For another the vcd::mosaic function calls strucplot and the code shows it is a pure grid function, so neither ggplot functions nor lattice functions are likely to be helpful.

IRTFM
  • 258,963
  • 21
  • 364
  • 487
  • Thanks for your help. This worked, but created new problems. Now the labels are actually sitting on top of the mosaic plot. I will try to research a way of moving them off to the left so nothing is obscured. – Katherine Nov 03 '15 at 21:46