- Instead of saving the figure directly as an EPS file, you can first save it as a PDF file, which provides better font support, and then convert the PDF file to EPS format.
- If converting to EPS format is not essential, you can try saving the figure directly as a PNG file instead of an EPS file. PNG files support font properties, including FontSize and FontWeight, without any issues.
How can I adjust FontWeight, FontSize and MarkerSize in legend and save the figure as eps.file without losing all these settings?
4 次查看(过去 30 天)
显示 更早的评论
The MATLAB version I am using is R2022b. I actually have done all the adjustment, but when I tried to save the figure as eps.file, the FontSize and FontWeight just disappeared and the MarkerSize adjustment remained. I have tried the savas and print function, but they didn't help. The settings still will be lost.
For the adjustment, I use the code below to modify the MarkerSize, FontWeight and FontSize.
[hl,icons,plots,legend_text]=legend('Scenario 1, \itP = \rm3','Scenario 2, \itP = \rm3','Scenario 1, \itP = \rm2','Scenario 2, \itP = \rm2',...
'Scenario 1, Conv.','Scenario 2, Conv.','Location','NW');
for ii = 1:6
icons(ii).FontSize = 14;
icons(ii).FontWeight = 'bold';
end
icons(8).MarkerSize = 20;
icons(10).MarkerSize = 20;
icons(12).MarkerSize = 20;
icons(14).MarkerSize = 20;
There is also a problem of this adjustment, as the legend box will not expand as the FontSize expands.
Meanwhile, I also don't get it why using
hl=legend('Scenario 1, \itP = \rm3','Scenario 2, \itP = \rm3','Scenario 1, \itP = \rm2','Scenario 2, \itP = \rm2',...
'Scenario 1, Conv.','Scenario 2, Conv.','Location','NW');
set(hl, 'FontSize',14,'FontWeight','bold')
can successfully adjust the FontSize and FontWeight. But, using
[hl,icons,plots,legend_text] = legend('Scenario 1, \itP = \rm3','Scenario 2, \itP = \rm3','Scenario 1, \itP = \rm2','Scenario 2, \itP = \rm2',...
'Scenario 1, Conv.','Scenario 2, Conv.','Location','NW');
set(hl, 'FontSize',14,'FontWeight','bold')
can not.
So, what should I do to adjust the the MarkerSize, FontWeight and FontSize of the legend, and save it without losing all the settings?
0 个评论
回答(1 个)
Shaik
2023-5-14
Hi,
The issue you're experiencing with saving the figure as an EPS file and preserving the adjustments made to the legend properties (MarkerSize, FontWeight, and FontSize) could be due to the way EPS files handle fonts and graphics.
EPS files are vector-based files that store graphics and text as mathematical descriptions. When saving figures in EPS format, some font properties may not be fully supported or may behave differently compared to other formats like PNG or PDF.
To address this issue, you can try the following:
By saving the figure as a PNG file, you should be able to preserve the adjustments made to the legend properties, including MarkerSize, FontWeight, and FontSize.
I hope one of these approaches helps you save the figure with the desired adjustments while maintaining the properties when using a standalone .exe or exporting to EPS format.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Response Computation and Visualization 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!