altmany / export_fig

A MATLAB toolbox for exporting publication quality figures
BSD 3-Clause "New" or "Revised" License
1.27k stars 365 forks source link

figure legend changed #360

Closed 12yyds closed 2 years ago

12yyds commented 2 years ago

if there is a need to change the fontsize and linewidth of the legend strings, the export_fig will change it back to default one no matter the settings. Does anyone find the solution? Thanks In some cases, the original figure is fine, when do the export_fig, there will be change of the legend line width and size.

afterexport_fig original

altmany commented 2 years ago

This report can be divided into 2 parts:

  1. Legend text font - After changing the legend object's text font (e.g. via its documented FontSize property) and then using export_fig, the updated font is reflected in both vector and raster outputs (e.g. PDF, PNG) using the latest version of export_fig using R2022b on Windows. After the export, the updated font remains unchanged in the exported figure - it does not change back to the default font. So your report cannot be reproduced and I do not see any problem with the existing code that requires fixing.

  2. Legend icon - Setting the legend icons' line width is not a supported property of the legend object. You can indeed modify it via some undocumented hacks (as I explained in my website), but after exporting the figure to vector format (PDF/EPS) the built-in Matlab print function (which is used internally, for the export) automatically reverts the icon to match the main plot line's color, width, style etc. Un-reverting the legend icon can be done using the very same hacks that you used to modify the legend icons originally. So again, I do not see a problem here that needs to be fixed.

Because of this, I'm closing this issue. However, if you see that there is still a problem with either the legend text font or icon that is not as explained above, then please post a comment here with a code snippet that shows the problem, as well as information about your run environment (latest export_fig version? which operating system? which Matlab release?).