I have a data frame with more than 40 factor levels and I would like to assign different shapes for each level. However, as shown in the scale_shapes_table of ggplot2
, I can assign only 26 of them and some !
,"
,#
and so on.
But I know that in python or jmp you can assign many shapes (like asteriks, left triangle ,right triangle, rectangle etc.). Is it also possible also in ggplot2
?
data=data.frame(gr=seq(1,40), x1=runif(40), y1=runif(40))
library(ggplot2)
ggplot(data=data,aes(x=x1,y=y1,shape=factor(gr),col=factor(gr)))+
geom_point(alpha = 0.3,size=4,stroke=1.4) +
scale_shape_manual(values=c(0:40))
Maybe use gr as labels, using ggrepel, easier to find a number than comparing shapes:
A large set of symbols is available using the
emojifont
package with Font Awasome (see the complete list here). More details are given here.Warning: if you want to use the code in Rstudio, first reassign the graphing device as follows:
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.
Or take advantage of the 5 unique shapes that take fill colors.