I use matlab2tikz to efficiently save Matlab plots as vector graphics for latex documents. I have axis scaling issues compared to the Matlab plot and the one rendered in my document.

The plot from Matlab looks like this: enter image description here

However the plot rendered using matlab2tikz and inside latex appears like this: enter image description here.

Since I do not know the aspect ratio of the plot, I see both \figureheight and \figurewidth equal. I have two questions:

  1. How to maintain aspect ratio as it is in Matlab, as the ellipse's aspect ratio needs to represented accurately?
  2. Both the x-and y-axes are overflowing (whitespace around the shaded plot). How to avoid this?
  • For 1., if you don't specify the width and height in the call to matlab2tikz, does that give you the correct aspect ratio? For 2., see if adding enlargelimits=false to the axis options in the generated file helps. – Torbjørn T. Nov 24 '16 at 20:14
  • For 1: I did not specify the width and height. Then, I get equal axis scales. However, the image is too large in tex document. I tried to scale it down. Then the plot fonts also decrease. For 2: It works! Please post it as answer! – Sathish Sanjeevi Nov 25 '16 at 11:00

Try using something like


when you call matlab2tikz. It appears that when you only specify the width like this, the height is set as a fraction of \figwidth as well, so you can keep that aspect ratio. enlargelimits=false should remove the whitespace around the plot.

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.