Assigning 40 shapes or more in scale_shape_manual
Would using a combination of 5 or 10 distinct shapes with distinct colors sufficient to distinguish the 40 points work better? I see these as being visually easier to differentiate the 40 elements than using/resorting to unusual symbols.
ggplot(data=data,aes(x=x1,y=y1, shape=factor(gr), col=factor(gr)))+
geom_point(alpha = 0.5, size=4, stroke=1.4) +
scale_shape_manual(values=rep(c(0:2,5:6,9:10,11:12,14), times=4))
Or take advantage of the 5 unique shapes that take fill colors.
ggplot(data=data,aes(x=x1,y=y1, shape=factor(gr), fill=factor(gr), col=factor(gr)))+
geom_point(alpha = 0.5, size=4, stroke=1.4) +
scale_shape_manual(values=rep(c(21:25), times=8))
A large set of symbols is available using the emojifont
package with Font Awasome (see the complete list here). More details are given here.
library(ggplot2)
library(emojifont)
set.seed(1234)
symbls <- c('fa-github', 'fa-binoculars', 'fa-twitter', 'fa-android', 'fa-coffee',
'fa-cube', 'fa-ambulance','fa-check','fa-cutlery','fa-cogs','fa-dot-circle-o','fa-car',
'fa-building','fa-fire', 'fa-flag','fa-female','fa-gratipay','fa-heart','fa-magnet',
'fa-lock','fa-map','fa-puzzle-piece','fa-shopping-cart','fa-star','fa-sticky-note',
'fa-stop-circle-o','fa-volume-down','fa-anchor', 'fa-beer','fa-book','fa-cloud',
'fa-comment','fa-eject','fa-chrome','fa-child','fa-bomb', 'fa-certificate',
'fa-desktop','fa-fire-extinguisher','fa-diamond')
idx <- order(symbls)
fa <- fontawesome(symbls)
k <- length(fa)
data=data.frame(gr=factor(fa, levels=fa[idx]), x1=runif(k), y1=runif(k))
data$gr <- factor(data$gr, levels=fa[idx])
ggplot(data, aes(x1, y1, colour=gr, label=gr)) +
xlab(NULL) + ylab(NULL) + geom_point(size=-1) +
geom_text(family='fontawesome-webfont', size=6, show.legend=FALSE) +
theme(legend.text=element_text(family='fontawesome-webfont')) +
scale_colour_discrete("Points",guide=guide_legend(override.aes=list(size=4)))
Warning: if you want to use the code in Rstudio, first reassign the graphing device as follows:
devtools::install_github("coatless/balamuta")
library("balamuta")
external_graphs()