# DotPlot for prime numbers

I was thinking to use a dotplot to give a description of prime numbers. On Wolfram website there is written that each dotplot can be built by

    DotPlot[data_] := Module[{m = Tally[Sort[data]]},
ListPlot[Flatten[Table[{#1, n}, {n, #2}] & @@@ m, 1],
Ticks -> {Automatic, Range[0, Max[m[[All, 2]]]]}]
]


I would like to have set of prime numbers on one axis and the natural numbers on the other one. Any idea? In addition, is it possible to realize a coprimality test by Dotplot (see figures below)?

I often investigate on Ramanujan primes. Is it possible to apply this procedure to them? I think so but which is the condition I should use? I am trying from several days with no results. According to wolfram references, the basic code from them is the following:

         l = Table[PrimePi[x] - PrimePi[x/2], {x, 10^4}]; // Timing

1 + Last[Position[l, #]][[1]] & /@ Range[0, 50]


These two simple lines provide the first 50 Ramanujan primes.

• Why are you destroying questions you've posted? – Kuba Mar 18 '19 at 11:24
• Because they are wrong! – Spook82 Mar 20 '19 at 0:23
• Questions are wrong? – Kuba Mar 20 '19 at 4:30

The code for DotPlot is a starting point that needs to be tailored (e.g., add or modify ListPlot options) for specific applications. It is not clear to me what you are asking for, so I have tailored DotPlot for displaying the prime factors of 50!

DotPlot[data_] := Module[{m = Tally[Sort[data]]},
ListPlot[Flatten[Table[{#1, n}, {n, #2}] & @@@ m, 1],
FrameTicks -> {Prime /@ Range[15], Range[0, Max[m[[All, 2]]], 4]},
Frame -> {{True, False}, {True, False}},
FrameLabel -> (Style[#, 14] & /@ {"Prime Factors", "Count"}),
PlotRange -> All,
PlotLabel -> Style["Prime Factors of 50!", 14, Bold]]]

data = Flatten[ConstantArray @@@ FactorInteger[50!]];

DotPlot[data]


EDIT: For co-primes use CoprimeQ and display table with TableForm or ArrayPlot

TableForm[
table = Table[Boole[CoprimeQ[m, n]], {m, 13}, {n, 13}],


table == Table[Boole[GCD[m, n] == 1], {m, 13}, {n, 13}]

(* True *)

ArrayPlot[table, FrameTicks -> {Range[13], Range[13]}]


Or

ArrayPlot[table, Mesh -> True, Frame -> True,
FrameTicks -> {Range[13], Range[13]}]


• Thanks for your reply. As I see the code for dotplot provides several tools to investigate in prime numbers. Do you think that it is possible to use the same approach to plot a coprimality test? I mean, we could use a dot if the numbers are coprime and nothing otherwise. I have attached to figures of what I would like to plot in my first post. – Spook82 Dec 18 '18 at 23:26
• @Spook82 - Neither of your figures appear to have anything to do with a DotPlot. You might want to look at TableForm or Grid and ArrayPlot. – Bob Hanlon Dec 18 '18 at 23:39
• Is it possible to realize them with these commands? Using the same structure of the code for Dotplot? – Spook82 Dec 19 '18 at 0:49