Save figure as image in R2014b without causing legend customization to revert

4 次查看(过去 30 天)
How can I keep the increases in line width in the legend of my plot when I save the figure as an image? It always reverts it to the corresponding data's line width and saves like that. When put into a document it is nearly impossible to tell what the line color is in the legend. I went back to my R2013b install and it worked no problem.
Using the following commands in both versions:
[hLeg,objLeg,outh,outm] = legend(...); set(objLeg,'LineWidth',5); saveas(hFig,[FileName '.png']);

回答(1 个)

Adam Hug
Adam Hug 2015-7-1
编辑:Adam Hug 2015-7-1
I think a better way of doing this is to adjust the linewidth of your plot. For example,
hold on
plot(t, sin(t), 'LineWidth', 5);
plot(t, cos(t), 'LineWidth', 5);
legend('Sine', 'Cosine');
hold off
saveas(gcf, 'test.png');
This way the "saveas" command will not trample over any changes you made to the legend. Additionally, you will be able to see the lines better in your image.

类别

Help CenterFile Exchange 中查找有关 Printing and Saving 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by