Is there a way to automatically create tally charts like the following from datavizcatalogue.com? I am in a Linux environment without any user interaction and no Adobe or Microsoft products. I would like to start a graphic software with a number (or a series of numbers) that would produce a small bitmap containing the tally-format number. The output should be jpg, png, etc. of similar resolution as in the example below.

I know that several (Windows/Linux) graphic software is capable of scripting/automatized output (Gimp, Inkscape, gnuplot, others?). Any Windows-based solution is also appreciated.

The important part for me is to have the tally marks created automatically, so that a number as input gives the same number in the tally mark numeral system as bitmap image.

Any hint is appreciated.

tally chart from datavizcatalogue.com

  • This would be very easy to create using most any logical programming language. What sort of format is your data going to be in? Apr 18, 2018 at 7:06
  • @ZachSaucier It is a simple ASCII file with the numbers (the "totals" in the image). It could also be just a number as input parameter for a script that creates a single tally-format number.
    – Aziraphale
    Apr 18, 2018 at 7:26
  • 2
    @Aziraphale what usecase? Web application, inside indesign/Illustrator/Photoshop, in Word etc. Here is a simple demo
    – joojaa
    Apr 18, 2018 at 7:42
  • @joojaa I am in a Linux environment, starting a script without any user interaction. I know that several graphic software (Windows/Linux-based) have scripting/automatization capabilities (Gimp, Inkscape etc.) so any Windows-based solution is also welcome. Thank you for the demo, it shows the math which brings me one step closer to the goal.
    – Aziraphale
    Apr 18, 2018 at 8:23
  • @Aziraphale thats kindof important, but what is the output an image file, PDF or a print?
    – joojaa
    Apr 18, 2018 at 8:26

1 Answer 1


Ok you can simply use postscript for this heres aencapsulated postscript example:

%!PS-Adobe-3.0 EPSF-3.0 
%%BoundingBox: 0 0 595 842
%%Creator: joo

/data (

Your 22
data 35
goes 12
here 23

) def 

/pw 595 def
/ph 842 def
/margin 40 def

margin 842 margin sub translate

/str 40 string def 
/Helvetica findfont 13 scalefont setfont 

/center { % x y string
    /string exch def
    /y exch def
    /x exch def
    0 0 moveto string dup stringwidth pop
    2 div x exch sub y moveto show
} def 

/drawtally { /num exch def
88 currentpoint exch pop translate
1 1 num { /i exch def
i 5 mod 0 ne { newpath 4 i mul  -2 moveto 4 i mul 10.5 lineto stroke fill} 
             { newpath 4 i 5 sub mul  -2 moveto 4 i mul 10.5 lineto stroke fill} ifelse
} for
} def 

/drawItem {/num exch cvi def /name exch def 32 currentpoint exch pop name center 
            num drawtally 
            432 595 margin 2 mul sub add 2 div currentpoint exch pop num str cvs  center} def

0.75 setlinewidth

% https://stackoverflow.com/a/14012570/1335032  
/split {
    [ 3 1 roll {  search { 3 1 roll }{ exit }ifelse }loop ]
    [ exch { dup () eq {pop} if} forall ]
} def

% Draw frame
0 0 moveto
pw margin 2 mul sub 0 lineto
pw margin 2 mul sub ph margin 3 mul sub neg lineto
0 ph margin 3 mul sub neg  lineto

0 -16 moveto
pw margin 2 mul sub -16 lineto
72 0 moveto
72 ph margin 3 mul sub neg lineto
432 0 moveto
432 ph margin 3 mul sub neg lineto

36 -12 (Title) center 
252 -12 (Tally) center 
432 595 margin 2 mul sub add 2 div -12 (Total) center 

%draw tallies
0 -32 moveto

data (\n) split {( ) split aload pop drawItem 0 -16 rmoveto} forall

You can use imagemagic or even ghostscript to convert that into a raster image. Or use the stuff directly for printing all form your command line. Ive rendered this with illustrator which also understands this.

enter image description here

  • This is interesting. I have never looked at Postscript code, so it is not easy to see at a glance what is happening there. But I guess you can program ANYTHING in PS, if you know the language.
    – Aziraphale
    Apr 18, 2018 at 14:16
  • 1
    @Aziraphale its actually a relatively simple stack language. one can learn it in 2 evenings. Unless you want to deal with certain corner things like character encoding.
    – joojaa
    Apr 18, 2018 at 14:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.