Exporting figure as pdf overlaps Axes border with numbers

6 views (last 30 days)
Construct of my figure which i export as a pdf: Subplot(2,2,1); Subplot(2,2,2); Subplot(2,2,[3,4];
The problem is in my subplot(2,2,2) which displays the figure correctly when i export it as png. But if i export it as pdf it overlaps the axes borders with the axes numbering.
Furthermore if i export it as eps it displays the figure correctly. So the problem is only when i export it as pdf. I´m very grateful about any feedback you could give me on this matter.
subplot(2,2,2); set(groot, 'defaultTextInterpreter', 'latex') set(groot,'defaultaxesfontname','cmu serif') plot(abs(data_matrix(:,8)),data_matrix(:,3),'.-r','LineWidth',1.5,'MarkerSize', 10); hold on plot(abs(data_matrix(:,10)),data_matrix(:,3),'.-','LineWidth',1.5,'Color',[0 0.6 0],'MarkerSize', 10); hold off grid on xlabel('$I_{leak}~\mathrm{[\mu A]}$','Color','k','FontWeight','bold','FontSize',12) ylabel('$I_{TLP}~\mathrm{[A]}$','Color','k','FontWeight','bold','FontSize',12) set(gca,'YAxisLocation','left') set(gca,'XAxisLocation','top') set(gca,'GridLineStyle',':') set(gca,'XColor','k','YColor',[0.8 0.8 0.8]); set(gca,'Color',[1 1 1])
if max(tlp_current_spot)> 0.1
set(gca,'YLim',[0 max(tlp_current_spot)],'YTick',0:round(10*(max(tlp_current_spot)/10))/10:1.1*max(tlp_current_spot))
else
%set(gca,'YLim',[min(tlp_current_spot) 0],'YTick',round(1.1*min(tlp_current_spot)):abs(round(10*(min(tlp_current_spot)/10))/10):0)
set(gca,'YLim',[min(tlp_current_spot) max(tlp_current_spot)],'YTick',round(1.1*min(tlp_current_spot)):abs(round(10*(min(tlp_current_spot)/10))/10):1.1*max(tlp_current_spot))
end
try
set(gca,'XLim',[1e-1*min([abs(data_matrix(:,8))' abs(data_matrix(:,10))']) 1e2*max([abs(data_matrix(:,8))' abs(data_matrix(:,10))'])])
catch
set(gca,'XLim',[0 1])
end
set(gca,'XScale','log')
%set(ax2, 'Layer','top')
grid off
%I Think problem might be somewhere in the next part ,because of adding two extra axis locations -bottom and left which is not used because its the same with my previous left axis%%
ax1=gca;
ax2=axes('Position',get(ax1,'Position'));
xlabel('$V_{TLP}~\mathrm{[V]}$','Color','k','FontWeight','bold','FontSize',12)
%set(ax2,'YAxisLocation','left');
set(ax2,'Color','none')
%set(ax2,'XColor','k','YColor','k');
%y-axis
set(ax2,'XAxisLocation','bottom');
set(ax2,'Color','none')
set(ax2, 'Layer','bottom')
axis tight
%set(gca,'box','on','ticklength',[0.22 0.25])
grid on
set(ax2,'GridLineStyle',':')
hold on
plot(ax2,data_matrix(:,2),data_matrix(:,3),'.-b','LineWidth',1.5,'MarkerSize',10,'Parent',ax2);
plot(ax2,data_matrix(start_index:stop_index,2),fit_neu,'-m','LineWidth',1.5,'Parent',ax2)
if crit_spot~=0 && max(tlp_current_spot)> 0.1
plot(ax2,[0 1.1*max(tlp_voltage_spot)],[data_matrix(crit_spot,3) data_matrix(crit_spot,3)],'black','LineWidth',1.5,'Parent',ax2);
plot(ax2,[data_matrix(crit_spot,2) data_matrix(crit_spot,2)],[0 1.1*max(tlp_current_spot)],'black','LineWidth',1.5,'Parent',ax2);
else
plot(ax2,[0 1.1*min(tlp_voltage_spot)],[data_matrix(crit_spot,3) data_matrix(crit_spot,3)],'black','LineWidth',1.5,'Parent',ax2);
plot(ax2,[data_matrix(crit_spot,2) data_matrix(crit_spot,2)],[0 1.1*min(tlp_current_spot)],'black','LineWidth',1.5,'Parent',ax2);
end
if max(tlp_current_spot)>0.1
set(ax2,'YLim',[0 max(tlp_current_spot)],'YTick',0:round(10*(max(tlp_current_spot)/10))/10:1.1*max(tlp_current_spot))
else
set(ax2,'YLim',[min(tlp_current_spot) max(tlp_current_spot)],'YTick',round(1.1*min(tlp_current_spot)):abs(round(10*(min(tlp_current_spot)/10))/10):1.1*max(tlp_current_spot) )
end
%x-axis
if max(tlp_voltage_spot)>0
set(ax2,'XLim',[0 1.1*max(tlp_voltage_spot)],'XTick',0:round (1.1 *max(tlp_voltage_spot)/5):1.1*max(tlp_voltage_spot))
else
% set(ax2,'XLim',[min(tlp_voltage_spot) 0],'XTick',round(1.1*min(tlp_voltage_spot)):abs(round(1*(min(tlp_voltage_spot)/7))/1):0)
set(ax2,'XLim',[1.1*min(tlp_voltage_spot) 0],'XTick',round(1.1*min(tlp_voltage_spot)):abs(round(1.1*(min(tlp_voltage_spot)/7))/1):0)
end
  2 Comments
Nitin Khola
Nitin Khola on 5 Nov 2015
I am unable to reproduce this issue. Is it possible for you to narrow down this issue by making a simple plot and then changing the properties like 'XAxisLocation' etc, as you suspect this issue could be related to those commands?
Further, what method are you using for exporting. Are you using "File-> Save As"? Have you tried using the "print" command? Refer to the following documentation for details on this command: http://www.mathworks.com/help/matlab/ref/print.html
There also exists a very popular FileExchange submission "export_fig" which might help you resolve the issue that you are facing. Refer to the following link for details. http://www.mathworks.com/matlabcentral/fileexchange/23629-export-fig
Tamas George
Tamas George on 10 Nov 2015
I am already using export fig to export the figure as pdf. If i use export_fig to export it as eps file the problem doesnt appear.

Sign in to comment.

Answers (0)

Categories

Find more on Printing and Saving 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!