Problems with ticks and grid lines when saving PDF

2 views (last 30 days)
I'm trying to save a plot which consists of a linear scale on the Y axis and a Log scale on the X axis. I want minor grid lines and ticks on both of the axis. The plot is being saved as a PDF, the figures themselves have everything I require if view the plots in full screen but the PDF document only has the ticks and grid lines on the Y axis.
Here is the code that I am using to save the PDFs:
save_graph = '2024_Stress_Vs_life.pdf';
figure(1);
scatter(Mayer(:,1),Mayer(:,2), 45, 'd');
hold on;
scatter(UHCF(:,1),UHCF(:,2), 45, '+');
hold on;
scatter(Stanzel(:,1),Stanzel(:,2), 45, 's');
hold on;
scatter(Chen(:,1),Chen(:,2), 45, 'x');
hold on;
scatter(Lesperance(:,1),Lesperance(:,2));
hold on;
set(gca,'xscale','log')
title ('Fatigue Life of Al2024 Comparison');
xlabel('Number of Cycles');
ylabel('Stress (MPa)');
grid(gca,'minor')
grid on;
set(gca,'FontSize',20);
set(gca,'YMinorTick','on','YMinorGrid','on');
set(gca,'XMinorTick','on','XMinorGrid','on');
legend('Mayer','UHCF','Stanzel','Chen','Lesperance','Location','Best');
saveas(figure(1),save_graph);
  1 Comment
xavier lesperance
xavier lesperance on 7 Sep 2019
I figured it out, I changed the orientation of the saved page and added tickmode manual on the X axis. Here is what the final code looks like:
save_graph = '2024_Stress_Vs_life.pdf';
figure(1);
scatter(Mayer(:,1),Mayer(:,2), 45, 'd');
hold on;
scatter(UHCF(:,1),UHCF(:,2), 45, '+');
hold on;
scatter(Stanzel(:,1),Stanzel(:,2), 45, 's');
hold on;
scatter(Chen(:,1),Chen(:,2), 45, 'x');
hold on;
scatter(Lesperance(:,1),Lesperance(:,2));
hold on;
set(gca,'xscale','log')
title ('Fatigue Life of Al2024 Comparison');
xlabel('Number of Cycles');
ylabel('Stress (MPa)');
grid(gca,'minor')
grid on;
set(gca,'FontSize',20);
set(gca,'YMinorTick','on','YMinorGrid','on');
set(gca,'XMinorTick','on','XMinorGrid','on','XTickMode','manual');
legend('Mayer','UHCF','Stanzel','Chen','Lesperance','Location','Best');
orient(figure(1),'landscape');
saveas(figure(1),save_graph);

Sign in to comment.

Answers (0)

Products


Release

R2015b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!