Skip to content
Prev 273944 / 398506 Next

Type of Graph to use

See if this gives you the presentation you want:

x <- read.table(textConnection("Name    Class
a             Class1
a             Class4
b             Class2
b             Class1
d             Class3
d             Class5
e             Class4
e             Class2"), header = TRUE)
closeAllConnections()
# add columns of numeric values of factors
x$name <- as.integer(x$Name)
x$class <- as.integer(x$Class)
# create plot area
plot(0
    , type = 'n'
    , xaxt = 'n'
    , yaxt = 'n'
    , xlab = ''
    , ylab = ''
    , xlim = c(0, max(x$class))
    , ylim = c(0, max(x$name))
    )
# now plot the rectangles
rect(
      xleft = x$class - 1
    , ybottom = x$name - 1
    , xright = x$class
    , ytop = x$name
    , col = x$name
    )
# add the labels
axis(1
    , at = seq(0.5, by = 1, length = length(levels(x$Class)))
    , labels = levels(x$Class)
    )
axis(2
    , at = seq(0.5, by = 1, length = length(levels(x$Name)))
    , labels = levels(x$Name)
    )
On Mon, Oct 10, 2011 at 6:49 AM, Jurgens de Bruin <debruinjj at gmail.com> wrote: