Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rotating y axis labels with mosaic plots

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!

like image 722
Katherine Avatar asked Sep 16 '25 14:09

Katherine


1 Answers

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.

like image 151
IRTFM Avatar answered Sep 19 '25 06:09

IRTFM