Bad quality pdf export

I created a plot, and then used the editor to make a 2D histogram aesthetically better. Then I saved the canvas as c code as well as as pdf and png. The problem is that although the png image is fair in quality, the pdf is really bad as seen below

.png


.pdf

The code to generate the canvas is given in a dropbox link because it’s rather large to put it as code or attach it.

First I opened the pdf with Okular so I thought that it could be the viewer so I tried Document Viewer but again the quality wasn’t that good too. What I mean by bad quality, is that the the top group is blur compared to the one in the bottom.

Why is this happening and most importantly can it be fixed?
Thank’s in advance!

P.S.: I am attaching the pdf just for refference
c11.pdf (957 KB)

I see:

You have a TH2F with 4096x4096 bins.
You draw it with the option COLZ.
Which means that a filled box is drawn for each bin.
Your canvas is roughly 1000x1000 pixels, which means that the boxes you are trying to draw are smaller than a pixel (you have, more or less, 16 boxes per pixel).
Some PDF viewers somehow get lost with that because they try to do smoothing… and smoothing 16 polygons on one pixel is not an easy task !!!
I see the same effect which “preview” on Mac. Turning off the smoothing makes it ok.
The Adobe viewer (which is the reference) is fine.

Indeed you are right!
I tried to use Acrobat Reader in Linux and indeed there was no problem!
Thank you very much for the information!

Also you can try to find in the setting of your preferred viewer if there is a way to change the smoothing behaviour. If there is one, turn it OFF. It should also fix the problem.