Matlab plot .eps file position legend is not same as in matlab plot

2 views (last 30 days)
Hello,
I want to save my plot as a .eps file. But when I open then the .eps file the legend is always inside the plot and not
in the right upper corner as in the real plot. See the picutres. How can I change that also in the .eps file the legend
is in the right upper corner?
Matlab plot:
.eps file:
Code:
M1 = readmatrix('1111');
M2 = readmatrix('2222');
M3 = readmatrix('3333');
M4 = readmatrix('4444');
M2(:,1) = M2(:,1) + M1(end,1) + 4;
M3(:,1) = M3(:,1) + M2(end,1) + 4;
M4(:,1) = M4(:,1) + M3(end,1) + 4;
M = [M1; M2; M3; M4];
% plot force data
subplot(2,1,1)
plot(M(:,1)/1000,M(:,2),'color',' [0, 0.4470, 0.7410]')
hold on
plot(M(:,1)/1000,M(:,3))
hold on
plot(M(:,1)/1000,M(:,4))
hold on
legend('Fx','Fy','Fz', 'Location', 'northeast')
grid on
h_xlabel = xlabel ({ '$t$\,/\,s'});
set(h_xlabel,'Interpreter','latex');
h_ylabel = ylabel ({'$F$\,/\,N'});
set(h_ylabel,'Interpreter',' latex');
% plot torque data
subplot(2,1,2)
plot(M(:,1)/1000,M(:,5),'color',' [0, 0.4470, 0.7410]')
hold on
plot(M(:,1)/1000,M(:,6))
plot(M(:,1)/1000,M(:,7))
legend('Mx','My','Mz', 'Location', 'northeast')
grid on
h_xlabel = xlabel ({ '$t$\,/\,s'});
set(h_xlabel,'Interpreter','latex');
h_ylabel = ylabel ({'$M$\,/\,Nmm'});
set(h_ylabel,'Interpreter',' latex');
grid on
h_xlabel = xlabel ({ '$t$\,/\,s'});
set(h_xlabel,'Interpreter','latex');
h_ylabel = ylabel ({'$s$\,/\,mm'});
set(h_ylabel,'Interpreter',' latex');
set(gcf,'units','centimeters');
set(gca,'FontSize',10,'FontName','Times');
print("title",'-depsc2');
  2 Comments
Mark S
Mark S on 5 May 2022
Edited: Mark S on 5 May 2022
I have tried that but also then the legend is inside of the plot in the .eps file. I have used now another solution. I have put the legend in the southwest corner. So that works fine for me.

Sign in to comment.

Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!