Is it possible to edit the axes labels for a mosaic plot from the vcd package?

落爺英雄遲暮 提交于 2019-12-10 15:55:59

问题


data("HairEyeColor")
mosaic(HairEyeColor, shade = TRUE)

Are there arguments I can use to change the labels on the margins of the resulting plot above? For instance, I'd like to change "Male" to "M", "Female" to "F", to avoid text encroachment, and make some notes in the title labels.

I can't find anything about editing axis labels in the package's help page.


回答1:


lnames <- list(Sex = c("M", "F"))
mosaic(HairEyeColor, set_labels=lnames, shade=T)

Or...

mosaic(HairEyeColor, set_labels=list(Sex = c("M", "F")), shade=T)




回答2:


The vcd package has an intricate system for adjusting labels -- see Labeling in the Strucplot Framework.

Labels can be abbreviated with abbreviate_labs. The vector order matches the order of the splits: Hair, Eye, Sex.

vcd::mosaic(HairEyeColor, shade = TRUE, labeling_args = list(abbreviate_labs = c(5, 5, 1)))



来源:https://stackoverflow.com/questions/39519608/is-it-possible-to-edit-the-axes-labels-for-a-mosaic-plot-from-the-vcd-package

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!