I have used matlab2tikz to plot an image as follows: enter image description here

As you can see, the red and blue zones on the image are highly blurred. I would like to know if there is any way that they can be sharpened. My tikz code is as follows:


The code seems very long but is just a series of axis environments and coordinates.


If you remove the line: shader=interp from all the addplots, then you get something that looks like this:

Less blurry

Which looks less blurred. Is this closer to what you want?

I couldn't plot all five spheres due to TeX internal memory limit, so that's something you'll need to solve.


Using the option shader=flat gives the same image but without the grid lines. Personally I think it looks better with the grid.

enter image description here

| improve this answer | |
  • I would prefer if there were no gridlines on each image. Would that be possible? – Sanjay Sekaran Sep 29 '15 at 11:39
  • @SanjaySekaran I updated my answer to an option without grid lines. It doesn't look very good though, perhaps you want to have a smoother map and not no grid lines? – user49901 Sep 29 '15 at 13:08
  • I would prefer something which doesn't look so blocky (a hybrid between the flat shader and interp shader variants) as well as without grid lines. Do you think that this would be achievable? – Sanjay Sekaran Oct 1 '15 at 2:05
  • @SanjaySekaran Try it with shader=faceted interp, it sort of looks like a mix. I hope that Feuersänger can give you more advice if needed. – user49901 Oct 1 '15 at 6:22
  • Unfortunately using shader=faceted interp is the same as shader=interp, except with gridlines drawn on the images. In any case, thank you for your help. – Sanjay Sekaran Oct 2 '15 at 1:34

The "blur" effect is due to the interpolation of color values. Keep in mind that "blur" is closely related to "averaging colors" and that is what many of the shaders to: they "average" colors in a smart way. Interpolation schemes are nice if you have (and expect) smooth transitions between adjacent patches in a mesh, but your images are inherently unsmooth. Consequently, the yellowish color dominates the interpolation schemes.

The solution is to switch to a non-interpolatory shader.

If you switch to shader=flat corner, you get

enter image description here

Note that shader=interp is a linear interpolation, shader=flat (which is equivalent to shader=flat mean) is constant interpolation using averaging and shader=flat corner uses the color of one of the corners (the first).

Note that this has a heavy effect on the last sphere: apparently, the cdata for the vertical slices is ignored in this way.

| improve this answer | |
  • I find that the flat shaders, while making the images very sharp, render the red and blue patches blocky. Is there a way to reach a compromise between the sharpness of the flat shader and the smoothness of the interp shader? Would increasing the number of defined colours in the colour gradient work? – Sanjay Sekaran Sep 30 '15 at 0:32
  • @SanjaySekaran I guess it would, yes -- provided you reduce the amount of yellowish colors in favor of other colors. – Christian Feuersänger Oct 2 '15 at 15:58
  • On an unrelated note, is there an easy way to reduce the size of each image (i.e. add some whitespace between each image)? I have been playing around with changing the axis limits and scaling but haven't managed to make it work. – Sanjay Sekaran Oct 2 '15 at 23:17
  • I suppose that should become a separate question in order to increase the question's visibility and its use to others. – Christian Feuersänger Oct 3 '15 at 9:08
  • I had already posted a question on this but had not received any reply. Hence my asking you here directly. – Sanjay Sekaran Oct 4 '15 at 1:32

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.