2
$\begingroup$

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)? enter image description here enter image description here

In addition,

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.

$\endgroup$
3
  • 4
    $\begingroup$ Why are you destroying questions you've posted? $\endgroup$
    – Kuba
    Mar 18, 2019 at 11:24
  • $\begingroup$ Because they are wrong! $\endgroup$
    – Spook82
    Mar 20, 2019 at 0:23
  • $\begingroup$ Questions are wrong? $\endgroup$
    – Kuba
    Mar 20, 2019 at 4:30

1 Answer 1

4
$\begingroup$

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]

enter image description here

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

TableForm[
 table = Table[Boole[CoprimeQ[m, n]], {m, 13}, {n, 13}],
 TableHeadings -> {Range[13], Range[13]}]

enter image description here

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

(* True *)

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

enter image description here

Or

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

enter image description here

$\endgroup$
3
  • $\begingroup$ 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. $\endgroup$
    – Spook82
    Dec 18, 2018 at 23:26
  • $\begingroup$ @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. $\endgroup$
    – Bob Hanlon
    Dec 18, 2018 at 23:39
  • $\begingroup$ Is it possible to realize them with these commands? Using the same structure of the code for Dotplot? $\endgroup$
    – Spook82
    Dec 19, 2018 at 0:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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