# [R], 239 bytes <!-- language-all: lang-r --> function(s){K=table(el(strsplit(gsub(" ","",s),""))) L=sum(K|1)+1 M=(M=max(K))+-M%%5+1 m=matrix(" ",L,M) m[2:L,M]=names(K) m[1,M-g]=paste0(g<-c(1,seq(5,M,5)),"-") m[1,]=format(m[1,],j="r") for(X in 2:L)m[X,M-1:K[X-1]]="X" write(m,1,L,,"")} [Try it online!][TIO-jfvhhtwy] [R]: https://www.r-project.org/ [TIO-jfvhhtwy]: https://tio.run/##fU7LbsIwELznK1aWkHaFI9WVuKD6C0LukVAOBpzgKrap7Qjo49vThd67h33MzM5uWiZ3SCbd0dtyjqdM1QBvNSzDHI7FxYCZvhpdzGGyaCfMJeXL5AqOeT6gACGFkJk4E1G103n22HwrWquq1dhqb27YEK3rdrXaMOgZKcndnqs72VLl969bbnodjLeZxYwo2dZjry8mF/uC41t9RCWz/cCNbOWG@Fwt/nS9HmJiS3wO8l2LxAxj2IELwNbk9x3bqW2z72rV91p0oromVyx6qfiHx@8/y4AixCu4DOVsoThvgV3ATBOMMZ7A2wAlwjEywfUhMu4EcXi0LjExh5Lun/@HoOUX "R – Try It Online" `table` does the heavy lifting here, uniquifying the characters, sorting them, and returning their counts. Everything else is just ensuring the offsets are right for printing, which is the "real" work of an ascii-art challenge. Thanks to [@dylnan](https://codegolf.stackexchange.com/users/75553/dylnan) for pointing out a bug.