# QuantilePlot silliness

When I do a quantile plot of two large data sets (in my case, each of them of size around 3 million), the resulting notebook cell is huge, and if you save it as PDF, the resulting PDF is 13MB in size. These things are so large that they choke Acrobat X Pro (it runs out of memory when trying to optimize them). Now, firstly, this is clearly a bug (it is a plot, so there is absolutely no reason to plot 3 million points, unless you want to show it to beings from Alpha Centauri), the questions are: has it always been thus, or is it a new bug, and (assuming I am not the first to run into this problem), what is the best work around you have found? (one can downsample the data before plotting, but that throws away information).

EXAMPLE This example is obviously bad, because in this case downsampling will change absolutely nothing, but it should show off the problem.

And By the way Since the files are too huge to be optimized or printed by Acrobat, the only solution I found was to do a screen grab (with Skitch) - thank God for Retina display, since that at least produces a decent res. Pretty gross, though.

data = RandomVariate[NormalDistribution[], {3000000}]
QuantilePlot[data, data]


(prepare to get a coffee while this is running, and save all work :()

• Could you supply a toy example to check on different versions and reproduce your problem? – Yves Klett Oct 10 '14 at 14:35
• Related, although perhaps you've read it already. – DumpsterDoofus Oct 10 '14 at 14:42
• @YvesKlett Sure, take a look at the edit. – Igor Rivin Oct 10 '14 at 14:45
• @DumpsterDoofus It is clearly related, but I am assuming there is some different mechanism, since in the example you linked to, it is hard to even imagine why the thing is so huge, whereas in my example I can think of a mechanism.... – Igor Rivin Oct 10 '14 at 14:47
• Perhaps a non-trivial example (plus semicolon after the first line) would really be more useful. What kind of plot would you rather prefer? – Yves Klett Oct 10 '14 at 14:51

The file size is considerably smaller (factor of 25+ with 300,000 data points) with use of the QuantilePlot option Joined->True

data = RandomVariate[NormalDistribution[], {300000}];

fbc1 = FileByteCount[Export[
"/Users/hanlonr/Desktop/Mma Temp/qPlot1.pdf", QuantilePlot[data, data]]] //
Timing


{15.540274, 5528588}

fbc2 = FileByteCount[
Export["/Users/hanlonr/Desktop/Mma Temp/qPlot2.pdf",
QuantilePlot[data, data, Joined -> True]]] // Timing


{13.489229, 200718}

fbc1/fbc2 // N


{1.15205, 27.5441}

• Wow, who would have thunk it! – Igor Rivin Oct 10 '14 at 23:48

Of course, you can Resterize and Export as it was pointed in comments. However let us do something less trivial. I propose to reduce the number of points and don't lose benefits of the vector format.

I don't wont to drink the coffee at evening so I use smaller number of points

data = RandomVariate[NormalDistribution[], {100000}];
p = QuantilePlot[data, data]


ByteCount[p]
(* 1607504 *)


We can span points to a fine grid and delete duplicates

p2 = p /. Point[pts_] /; Length[pts] > 100 :> Point@DeleteDuplicates@Round[pts, 0.01]


There is no visible difference but the size is sufficiently smaller

ByteCount[p2]
(* 19760 *)

• That's a nice method, but what is the advantage over the Rasterize[] approach (I see one: it does not screw up the ticks, etc - is that what you had in mind? – Igor Rivin Oct 10 '14 at 20:34
• @IgorRivin Not only. You can zoom the vector figures and see small details. Also I often make some manual post-processing in a vector editor to obtain publication quality figures (tuning dashing of the lines, adding some arrows and LaTeX formulas, etc.). – ybeltukov Oct 10 '14 at 20:49