1

I have this mosaic plot enter image description here

I'd like to have only label on x-axis for individuals in correct facet.

for example you can see that in the last facet there are only 7 bars. i'd like to show only x axis labels for those 7 bars.

Hope i have been clear enough

here's my code and data

p<-ggplot(data = newdata) +
       geom_mosaic(aes(weight = frequency, x = product(region),fill=factor(categ)),na.rm=TRUE) +facet_grid(~cutt) +theme(axis.text.x=element_text(angle=90, hjust= .1))+
      guides(fill=guide_legend(title = "Type of Crime", reverse = TRUE))`


 head(newdata)
   region               categ frequency median_income    cutt vec
1 alabama            burglary   0.25773         42917 39k-51k   0
2 alabama             larceny   0.67646         42917 39k-51k   0
3 alabama motor_veichle_theft   0.06581         42917 39k-51k   0
4 arizona            burglary   0.20239         50036 39k-51k   0
5 arizona             larceny   0.71590         50036 39k-51k   0
6 arizona motor_veichle_theft   0.08171         50036 39k-51k   0
Marco Fumagalli
  • 2,307
  • 3
  • 23
  • 41

0 Answers0