1 / 2

Explaining Matlab’s Axis Alignment

Explaining Matlab’s Axis Alignment

ping
Download Presentation

Explaining Matlab’s Axis Alignment

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Explaining Matlab’s Axis Alignment When it deems it practical, Matlab tries to setup axis positions so that when the figures are included in documents like this one, multiple axes line up nicely. This means that, except when the axis is very small, a constant amount of padding is used, whether or not there is a title or x/y axis labels. The above figures were captured from Matlab one at a time. Note that the top row and the lower left sub figures are all nicely aligned with each other. The lower right one however was deemed too small so Matlab adjusted the top, bottom, and left padding of the axis to make it fit, breaking the alignment. This makes it look bad in a professional document. These images were generated as follows. First we resized the figure window manually and told Matlab to copy figures based on window size (as opposed to the paper size). Then we ran the following code, “clf;plot(rand(10));”, copied the figure, then ran “clf;plot(rand(3)); title('With 3 random lines'); xlabel('x axis'); ylabel('y axis');”. We then resized the window and repeated the process.

  2. Using SUBPLOT to Keep Alignment This figure was created using subplots inside matlab (instead of being created as 4 separate figures. In this case, Matlab does keep the alignment. It looks nice in a professional document. Code: subplot(3,2,[1 3]); plot(rand(10)); subplot(3,2,[2 4]); plot(rand(3)); title('With 3 random lines'); xlabel('x axis'); ylabel('y axis'); subplot(3,2,5); plot(rand(10)); subplot(3,2,6); plot(rand(3)); title('With 3 random lines'); xlabel('x axis'); ylabel('y axis'); Using SUBPLOT or AXES to Override Alignment If you wish to have finer control over the positioning of the axes, you can use the axes or subplot commands with the optional ‘Position’ parameter. For example, I often want the exported plot to contain only the area inside the axes and not the axis labels, the ticks, the title, or anything else. “subplot(‘Position’, [0 0 1 1]);” does this for me. Other times I find that trickier work is needed if I want good alignment on small subfigures, but the idea is the same.

More Related