Using print function to save figures with text labels
12 次查看(过去 30 天)
显示 更早的评论
I have often saved multi-part figures using the print function, but recently labels added to these with the text function are no longer being saved in the final image (example below). I explored other options including exportgraphics and saveas, however none have the functionality of 'print'. The same disappearing-text issue is present independent of figure extension (.png, .pdf, etc.). What would be the best way to get the saved image, in this case testfigure.png, to look like the Matlab figure window?
figure(1);clf;
x=linspace(0,2*pi,10);plot(sin(x),'linewidth',2);
t=text(0.8,0.9,'my function','units','normalized'); %label appears in figure window
print('testfigure.png','-dpng','-r300');set(t,'fontweight','bold'); %label is missing in .png file
2 个评论
Catalytic
2023-9-6
I explored other options including exportgraphics and saveas, however none have the functionality of 'print'.
The functionality you're struggling to find in other functions is critical information for us. Otherwise we can't know what to recommend. You can forget about getting print() to work the way you want. It's notoriously bad.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Printing and Saving 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!