Keep in mind that 10^10 points is an outrageously large amount of computation no matter what hoops you jump through. Even something much more modest, say 10^7 points, is going to eat up your RAM when using any Graphics
object to store it all in.
I suggest creating a series of rasterized images and using some basic image processing to join them together. The following code does that, though I warn you, it is slow. The plus side is that it won't run you out of memory!
primePercent[x_Integer] := 100 PrimePi[x]/x
Here step
, max
, and isize
are the number of points to plot in intermediate images, the total number of desired points, and the image size respectively.
step = 10^5;
max = 10^7;
isize = 500;
I store an initial image img0
.
img0 = Rasterize[
DiscretePlot[primePercent[k], {k, step},
PlotRange -> {{0, max}, {0, 60}}, ImageSize -> Full,
Filling -> None, Joined -> True], ImageSize -> isize];
Here, I set up a dynamic progress indicator. Its nice to know how long you have to wait if you are going to be waiting a while!
Dynamic[ProgressIndicator[(i/max)]]
This is where I put it all together. I'm using ImageMultiply
to combine rasterized images. This will overemphasize repeated components which is why AxesStyle
is set to 0 opacity.
Do[img0 =
ImageMultiply[img0,
Rasterize[
DiscretePlot[primePercent[k], {k, i - step + 1, i},
PlotRange -> {{0, max}, {0, 60}}, ImageSize -> Full,
Filling -> None, Joined -> True,
AxesStyle -> Directive[Opacity[0]]], ImageSize -> isize]]
, {i, 2 step, max, step}
]
The resulting image looks like...
The easiest first step to getting a higher quality image would be to set isize
to something larger.
Edit: As David points out in his response, it is better for this particular example to specify a step size in DiscretePlot
. Only use the method I've provided if David's approach isn't reasonable for your particular application.