Search code examples
raxis-labelsmosaic-plot

The captions of my graph are overlapping. How can I fix this?


So I was plotting this code, but the text is overlapping. How can I fix this? enter image description here

mayors <- read.csv("https://raw.githubusercontent.com/umbertomig/intro-prob-stat-FGV/master/datasets/brmayors.csv")
head(mayors)

mosaicplot(table(mayors$SIGLA_PARTIDO, mayors$DESCRICAO_SEXO), main = "Gender by party", color = "turquoise")

mosaicplot(table(mayors$SIGLA_PARTIDO, mayors$DESCRICAO_GRAU_INSTRUCAO), main = "Level of education by party", color = "plum")

enter image description here


Solution

  • You can control the direction of the axis labels with las =. You can also control the size of the text with cex.axis =.

    mosaicplot(table(mayors$SIGLA_PARTIDO, mayors$DESCRICAO_GRAU_INSTRUCAO),
               main = "Level of education by party",
               color = "plum",
               las = 2,
               cex.axis = 0.5)
    

    enter image description here