The visualization of categorical data is a grossly understudied domain and, in spite of some fairly powerful and compelling visualization methods, these techniques remain relatively unpopular.
My favorite method for graphically illustrating contingency tables is to use a mosaic plot. To make mosaic plots, we will need to install and load the VCD (Visualizing Categorical Data) package:
install.packages("vcd") library(vcd) ucba <- data.frame(UCBAdmissions) mosaic(Freq ~ Gender + Admit, data=ucba, shade=TRUE, legend=FALSE)
After loading the preceding package the output obtained will be as follows: