Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a matrix where each element represents a pixel. I want to plot the matrix (possibly with ArrayPlot). To suppress aliasing in the final graphic (which I will then export as a png), I am currently disabling any axis, caption and so on, and I'm forcing the size of the image to match the dimension of the matrix with ImageSize. I get the desired result, but I need to show the axes. Is there a way to do it?

share|improve this question
Maybe you should check out the PixelConstrained option. – einbandi Nov 20 '12 at 14:30
@einbandi excellent, post it as an answer – Lorenzo Pistone Nov 20 '12 at 14:38
For a method including labels see my answer to (28246) – Mr.Wizard Feb 4 '15 at 14:44

Say you have a large array like:

array = Table[RandomReal[], {i, 200}, {j, 200}];

To align the cells of arraywith pixels, use the PixelConstrainedoption:

ArrayPlot[array, PixelConstrained -> True]

enter image description here

share|improve this answer
Unfortunately, this does not seem to help if I add the the Frame: the final output size (including frame and ticks) is the dimension of the matrix, and this of course causes stretching in the data plotting. I have tried also with Show[Image[mydata, ImageSize->Automatic, Magnification->1], Axes->True], same behaviour. – Lorenzo Pistone Nov 21 '12 at 10:33
This is true, I didn't notice that with my minimal example. You might be able work around that by using PixelConstrained->{2,2} (or even more?) and appropriate ImagePadding settings, along with a BaseStyle that fits your demands. This way you might get rid of the aliasing. – einbandi Nov 21 '12 at 22:21

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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