plot tick justification error in EPS file
10 views (last 30 days)
Show older comments
On a plot, I have replaced x-ticks with text and then rotated them through 90 degrees. When printing to EPS format (top image), the text is centrally justified and crosses the x-axis. When I print to PNG (bottom image), the text is right justified and does not cross the x-axis. Furthermore, the font in the EPS image is incorrect; it should be Garamond but appears to be Courier New. How can I correct these two issues?


0 Comments
Answers (1)
Kiran Felix Robert
on 4 Nov 2020
Hi Benjamin,
This happens because the X axis ticks in the figure are set to 'Auto' and the X axis is rescaled when the figure is resized for exporting.
To avoid this refer the following code snippet to set the X Axis ticks to ‘Manual’
X = 1:5;
Y = X.^2;
f = figure;
plot(X,Y);
ax = gca;
names = {'One';'Two';'Three';'Four';'Five'};
ax.XTick = [1:5]; % Ticks
ax.XTickLabel = names; % Tick Lables
ax.XTickLabelRotation = 90; % Rotation
ax.XTickMode = 'Manual'; % Manual X Ticks Mode
ax.FontName = 'Garamond'; % Font
print(f,'png','-dpng','-opengl')
print(f,'eps','-deps','-opengl')
Kiran Felix Robert
2 Comments
See Also
Categories
Find more on Line Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!