MATLAB: In printing MATLAB figures to PDF in landscape mode, how can I print such that in the PDF file, the figure is not rotated 90 degrees clockwise

MATLAB

Usually when printing in landscape to a PDF file, the figure in the file is rotated 90 degrees clockwise. I would like the figure to be rotated back 90 degrees for easy viewing.

Best Answer

The ability to print a figure to a PDF file in landscape mode such that the figure (and the paper) in the file is oriented horizontally for easy viewing is not available in MATLAB. This applies to all formats.
To work around this issue, you need to flip the paper's size, as shown in the example code below:
hf = figure;
peaks;
set(hf,'PaperSize',fliplr(get(hf,'PaperSize')))
print(hf,'-djpeg','test')
!test.jpg