graph - fix annotation so that they dont move when converted to .tif/.eps/.pdf

Hi,
maybe someone can halp me out with my problem: I want to generate a plot in Matlab with the code below and then convert it to .tif/.eps/.pdf - format (via "export" or "save as . . ." ). However when converting the format the positions of the annotations change (same happens when the plot editor is started).
Is there any command to fix the relative position annotations or to avoid the scaling of the graph when converted to .tif/.eps/.pdf - format?
cheers Patrick
%M-File to create PLOT_.xls
del= [30,100,200,300,400,500,570];
y_I= [60, 60,60,60,60,60,60];
y_II=[60.94, 63.048,65.860,68.464,70.880,73.129,74.613];
%Definition der Achsenabstände und Längen
x0 = 0;
xe = 600;
xint = 4;
y0 = 55;
ye = 75;
yint = 4;
figure ('color','w','un','pix','pos',[360 150 500 390], 'PaperPositionM','auto','Invert','off','rend','Painters');
axes('un','pix','pos',[100,90,350,260],...
'box','on',...
'LineWidth',2,...
'FontName','times',...
'FontSize',22,...
'ylim',[y0 ye],...
'YTick', y0:(ye-y0)/yint:ye,...
'xlim',[x0 xe],...
'XTick', x0:(xe-x0)/xint:xe);
hold on
plot(del, y_I, 'b', 'LineWidth', 4)
plot(del, y_II, 'r', 'LineWidth', 4)
% Create arrow: x-Achsenpfeil
annotation('arrow',[0.76 0.84],[0.043 0.043]);
% Create arrow: y-Achsenpfeil
annotation('arrow',[0.045 0.045],[0.86 0.94]);
% Create textbox: Einheiten Beschriftung an der
% x-Achse%'HorizontalAlignment','center',...
annotation('textbox',[0.79 0.105 0.05 0.1],...
'String',{'x'},...
'FontSize',22,...
'FontName','times',...
'LineStyle','none');
% Create textbox: Einheiten Beschriftung an der y-Achse %
% 'HorizontalAlignment','center',...
annotation('textbox',[0.118 0.79 0.05 0.1],'String',{'%'},...
'FontSize',22,...
'FontName','times',...
'LineStyle','none');
xlabel('labelx \Delta x','FontName','times','FontSize',25);
ylabel('labely \eta_{y}','FontName','times','FontSize',25);
hold off
print(gcf, '-dpdf', '-r150','-painters', '-loose', 'figure.pdf')

1 commentaire

Can you format the code please: http://www.mathworks.com/matlabcentral/answers/7885-tutorial-how-to-format-your-question

Connectez-vous pour commenter.

 Réponse acceptée

Explicitly define the dimensions of figure and axes with some additional properties:
h.f = figure('color','w','un','pix','pos',[360 150 500 390],...
'PaperPositionM','auto','Invert','off','rend','Painters');
h.a = axes('un','pix','pos',[100,90,350,260],...
'Ylim',[y0,ye],'Ytick',y0:(ye-y0)/yint:ye,...
'Xlim',[x0 xe],'Xtick', x0:(xe-x0)/xint:xe,...
'box','on','fonts',22,'LineW',2,'FontN','times');
hold on
plot(del, y_I , 'b', 'LineWidth', 4)
plot(del, y_II, 'r', 'LineWidth', 4)
% Then to export:
print(gcf, '-depsc2', '-r150','-painters', '-loose', 'figure.eps')
EDIT
Try export_fig to save (on FEX) in pdf.

Plus de réponses (1)

Patrick
Patrick le 4 Août 2011
Thanks Oleg,
i updated the the code and tried to format it, however it doesn't work out. The vector-image contains 2 or more layers (at least that is what infer) which are scaled independently to each other, does anyone know how to fix/pin them together?
Thanks once more Patrick ps: using Version 7.8.0 on Mac

6 commentaires

Yes, but you didn't explicitly declare the dimensions of both figure and axes as I wrote on my example.
i did, sorry code is now properly updated.
So, you just have to reposition your annotations in the new layout (which I didn't do for you) but when you print the figure is the same as in Matlab, isn't it?
no, unfortunately not, if i open the .eps/.pdf-file outside matlab it moves around again. i could add the annotations in PowerPoint and print as .pdf-file, but i actually thought i could avoid that extra step.
Try then to use export_fig. I put the link in my edited answer.
seams to work for .tif that should do the job. Great thanks!

Connectez-vous pour commenter.

Catégories

En savoir plus sur Creating, Deleting, and Querying Graphics Objects dans Centre d'aide et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by