# Display Table output as a grid of points

I want to create a Grid or Plot (or equivalent) from the following Table:

Module[{size = 10}, Table[If[PrimeQ[a + b], True], {a, 1, size}, {b, 1, size}]]

(*
{{True, True, Null, True, Null, True, Null, Null, Null, True},
{True, Null, True, Null, True, Null, Null, Null, True, Null},
{Null, True, Null, True, Null, Null, Null, True, Null, True},
{True, Null, True, Null, Null, Null, True, Null, True, Null},
{Null, True, Null, Null, Null, True, Null, True, Null, Null},
{True, Null, Null, Null, True, Null, True, Null, Null, Null},
{Null, Null, Null, True, Null, True, Null, Null, Null, True},
{Null, Null, True, Null, True, Null, Null, Null, True, Null},
{Null, True, Null, True, Null, Null, Null, True, Null, True},
{True, Null, True, Null, Null, Null, True, Null, True, Null}}
*)


I want the output to have the following properties:

1. The two 'axes' a and b are marked, and have ticks at integer values;
2. There is a grid of lines showing integer intervals from both axes;
3. At each intersection with Cartesian coordinates (a,b) where the Table output is True, there should be a Point; at Null points there should be nothing.

This seems like it should be really simple, but for some reason I can't quite get my head around the syntax...

How do I do it?

• Many thanks for the excellent answers. I have chosen the most general one to mark as answered, but they are all both useful and instructive. Commented Jun 26, 2020 at 21:31

Inspired by @kglr and extending to arbitrary dimensions on the data, this may do what you want:

data = Module[{size = 11},
Table[If[PrimeQ[a + b], True], {a, 1, size}, {b, 1, size}]];
With[{elements = Max[Dimensions[data]]},
ListPlot[Position[data, True],
PlotStyle -> Directive[Black, PointSize[Large]], Frame -> True,
AspectRatio -> 1,
FrameTicks -> {{Range[elements],
GridLines -> {Range[elements], Range[elements]},
PlotRange -> {{1, elements}, {1, elements}},
PlotRangeClipping -> False]]


Shown with size set to 11 to show that it fits the generality.

Visualized as squares rather than points

ArrayPlot[data,
Frame -> True,
FrameTicks -> {{Range@10, Range@10}, {Range@10, Range@10}},
DataReversed -> True,
Mesh -> All]


How about BubbleChart?

tab = With[{n = 10}, PrimeQ @ Array[Plus, {n, n}]];

BubbleChart[Append[1] /@ Position[tab, True], GridLines -> (Range[1, #2] &)];

Labeled[%, {"A", "B"}, {Bottom, Left}]


Adding FrameTicks -> (Range[1, #2] &) gives:

Since V 12.2 we can also use PointValuePlot

Borrowing tab from Mr. Wizard:

tab = With[{n = 10}, PrimeQ @ Array[Plus, {n, n}]];

PointValuePlot[