My troubles started when I had a variable with more than 6 values because that is the current maximum value for the scale_shape function in ggplot2.
Due to that problem
Further trick: If you give either legend a name, you must give them both the same name. If you give only one legend a name, ggplot will separate the legends again. Amending kohske's example:
plot1 <- ggplot(dataf, aes(x=Density, y=Growth, colour=Municipality,
shape=Municipality)) + geom_point(size=3)
plot2 <- plot1 + scale_colour_discrete() +
scale_shape_manual(values=as.numeric(dataf$Municipality))
plot2
plot3 <- plot1 + scale_colour_discrete('City') +
scale_shape_manual(values=as.numeric(dataf$Municipality))
plot3
plot4 <- plot1 + scale_colour_discrete('City') +
scale_shape_manual('City',values=as.numeric(dataf$Municipality))
plot4