-1
$\begingroup$

I often investigate on Ramanujan primes. Is it possible to apply this procedure described in DotPlot for prime numbers ? 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. In particular, the primes are drawn in black in a binary image as shown below.

enter image description here

Is it possible to do the same with the Ramanujan primes? I mean, drawing black only the Ramanujan primes!

$\endgroup$
  • $\begingroup$ I rolled back your latest edit that removed the contents of your question. Since somebody put in effort to answer your question, you should leave it intact so their answer makes sense. $\endgroup$ – MarcoB Mar 18 at 13:32
5
$\begingroup$

It is not clear how you want these Ramanujan primes displayed. The following uses NumberLinePlot (introduced in v10.0)

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

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

NumberLinePlot[Tooltip /@ rp, ImageSize -> Large]

enter image description here

EDIT: Using ArrayPlot with Manipulate

Manipulate[
 ArrayPlot[
  Array[Boole[MemberQ[rp, #1] && MemberQ[rp, #2]] &, {rp[[n]], 
    rp[[n]]}],
  FrameTicks -> Range[0, rp[[n]], Max[2, Round[rp[[n]]/10, 5]]]],
 {{n, 6}, 1, 25, 1, Appearance -> "Labeled"}]

enter image description here

EDIT 2:

Manipulate[
 ArrayPlot[Reverse@Array[
    Boole[MemberQ[rp, #1] && MemberQ[rp, #2]] &, {rp[[n]], rp[[n]]}], 
  FrameTicks -> {Table[{rp[[n]] - m + 1, m}, {m, rp[[1 ;; n]]}], 
    rp[[1 ;; n]]}],
 {{n, 6}, 3, 12, 1, Appearance -> "Labeled"}]

enter image description here

$\endgroup$
  • 1
    $\begingroup$ @Spook82 - I have guessed at what you may want; however, in the future specify exactly what you expect on each axis of a plot. Otherwise your questions may be closed as requiring additional information. $\endgroup$ – Bob Hanlon Dec 30 '18 at 20:12
  • $\begingroup$ Dear Bob, thanks a lot and my sincerest apologies for my lack of details. In addition, I would like to know how I can invert the order of the axis-colomn. I mean that it should go from 0 to 45 and not from 45 to 0 as in the uploaded figure. I tried with the commands "rotate" and "reverse" but I did not work. The problem is that "Manipulate is not a graphic command" and I am not able to modify the "FrameTicks" in the code. I hope I was enough clear. $\endgroup$ – Spook82 Dec 31 '18 at 4:18

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.