How to avoid marker clipping while saving two axis figure to pdf?
Ältere Kommentare anzeigen
Hi everyone,
I have some trouble while exporting a two axis figure to pdf. The following example code works great while creating the figure in Matlab. But in the generated pdf-file all my red markers on the x-axis get cut off (see screenshot). Curiously this problem only occures, when I use a two axis plot

fig = figure;
x = linspace(0,25);
y = sin(x/2);
marker = linspace(0,25,5);
yyaxis left
plot(x,y,'g');
hold on;
r = x.^2/2;
yyaxis right
plot(x,r,'b');
hold on;
plot(marker,0,'rx','Markersize', 8);
saveas(gcf,'myfigure.pdf');
Can anyone please help me out here?
Akzeptierte Antwort
Weitere Antworten (2)
Michel Herke
am 13 Sep. 2018
Bearbeitet: Michel Herke
am 13 Sep. 2018
2 Kommentare
Yes, the labelling changes the axes position of only one axes. Add this at the end of the script before you print.
ax(2).Position=ax(1).Position
As a sidenote, please use the "comment" instead of "answer" for anything other than actual answers :)
Michel Herke
am 17 Sep. 2018
Kategorien
Mehr zu Two y-axis finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

