Function Repository Resource:

RaggedDigitsPlot

Source Notebook

Plot an array of digits, allowing them to be ragged on the left

Contributed by: Wolfram Research

ResourceFunction["RaggedDigitsPlot"][list]

plots the list of binary digit sequences in list, showing them as ragged on the left.

ResourceFunction["RaggedDigitsPlot"][list,b]

assumes digits in base b.

ResourceFunction["RaggedDigitsPlot"][list,b,n]

uses n digits of padding on the left.

Details and Options

ResourceFunction["RaggedDigitsPlot"] generates a plot similar to the plots that appear in A New Kind of Science, page 560 (section 10.5).
ResourceFunction["RaggedDigitsPlot"] supports the options ColorData, ColorRules, Mesh, MeshStyle, and "Label", as well as the options supported by Graphics.
The Mesh and "Label" options take the values True or False.

Examples

Basic Examples (3) 

Plot binary digit sequences of successive numbers:

In[1]:=
ResourceFunction["RaggedDigitsPlot"][
 Table[IntegerDigits[n, 2], {n, 20}]]
Out[1]=

Plot ternary digit sequences:

In[2]:=
ResourceFunction["RaggedDigitsPlot"][
 Table[IntegerDigits[n, 3], {n, 10}], 3]
Out[2]=

Include padding equivalent to three digit positions on the left:

In[3]:=
ResourceFunction["RaggedDigitsPlot"][
 Table[IntegerDigits[n, 2], {n, 20}], 2, 3]
Out[3]=

Scope (1) 

Customize the appearance of the plot:

In[4]:=
ResourceFunction["RaggedDigitsPlot"][
 Table[IntegerDigits[n, 2], {n, 20}], 2, 3, Background -> LightBlue, ColorFunction -> ColorData["WebSafe"], MeshStyle -> Directive[Blue, Opacity[0.4], Thickness[.02]], Frame -> True, PlotLabel -> "Digits", PlotRangePadding -> 1]
Out[4]=

Options (4) 

ColorFunction (1) 

Select color maps:

In[5]:=
ResourceFunction["RaggedDigitsPlot"][
 Table[IntegerDigits[n, 2], {n, 20}], 2, 3, ColorFunction -> "BrightBands", Mesh -> True]
Out[5]=
In[6]:=
ResourceFunction["RaggedDigitsPlot"][
 Table[IntegerDigits[n, 2], {n, 20}], 2, 3, ColorFunction -> ColorData[{"TemperatureMap", "Reverse"}], Mesh -> True]
Out[6]=

ColorRules (1) 

Specify individual colors for values:

In[7]:=
ResourceFunction["RaggedDigitsPlot"][
 Table[IntegerDigits[n, 3], {n, 20}], 3, ColorRules -> {0 -> Red, 1 -> Blue, 2 -> Yellow}]
Out[7]=
In[8]:=
ResourceFunction["RaggedDigitsPlot"][
 Table[IntegerDigits[n, 2], {n, 20}], 2, 3, ColorRules -> {0 -> Blue}]
Out[8]=

Label (1) 

Add labels to the cells:

In[9]:=
ResourceFunction["RaggedDigitsPlot"][
 Table[IntegerDigits[n, 2], {n, 20}], "Label" -> True]
Out[9]=
In[10]:=
ResourceFunction["RaggedDigitsPlot"][
 Table[IntegerDigits[n, 2], {n, 20}], 2, 3, ColorRules -> {0 -> Blue},
  "Label" -> True]
Out[10]=

Mesh (1) 

Hide Mesh:

In[11]:=
ResourceFunction["RaggedDigitsPlot"][
 Table[IntegerDigits[n, 2], {n, 20}], 2, 3, ColorFunction -> GrayLevel, Mesh -> False]
Out[11]=

Requirements

Wolfram Language 11.3 (March 2018) or above

Version History

  • 2.0.1 – 17 March 2021
  • 2.0.0 – 05 October 2020
  • 1.0.0 – 14 January 2019

Author Notes

The original code was developed by Stephen Wolfram. The option of adding labels was added later as a feature of RaggedDigitsPlot by the Wolfram Research team.

License Information