graph - fix annotation so that they dont move when converted to .tif/.eps/.pdf
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentario
Oleg Komarov
el 4 de Ag. de 2011
Can you format the code please: http://www.mathworks.com/matlabcentral/answers/7885-tutorial-how-to-format-your-question
Respuesta aceptada
Oleg Komarov
el 4 de Ag. de 2011
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
0 comentarios
Más respuestas (1)
Ver también
Categorías
Más información sobre Specifying Target for Graphics Output en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!