Here is a quick update on the comments I have previously given to obtain nice figures in MATLAB. As you probably know, two of the most common plagues during export are font inconsistency (usually microscopic ticks and labels) and bad export quality for raster (PNG, JPG) formats. I will also give a small tip at the end to improve readability and general aesthetics for markers.
(Finally) Achieve a good agreement between LaTeX and MATLAB fonts
Quick recap from last time : in MATLAB, the figure size on screen and the one on the printed focument (PNG, EPS, PDF file) are not per se related. We have to force these two sizes to coincide. We can write, for example :
mysize = [16 10]; % in centimeters set(gcf, 'Units', 'centimeters', 'paperunits', 'centimeters', 'papersize', ... mysize, 'paperposition', [0 0 figsize], 'position', [0 0 figsize]); % then my figure is assuredly "correct" both on screen and print
The document will then have a 16 x 10 cm size during export. Work is not done yet, though. For an even better agreement, we need the figure width to be of the same size as the column (or text) width. You can get it typing :
\the\columnwidth % One column width in multiple column environment \the\textwidth % The width of the page (regardless of number of columns)
in your LaTeX document. I have gathered some values used by journals I tried to publish in:
|Journal||Column (pt)||Column (cm)||Text (pt)||Text (cm)||Font size (pt)|
|Physical Review Fluids||/||/||504 ?||17.79 ?||11 ?|
|Soft Matter (RSC)||255||8.99||529||18.66||9|
|Institute of Physics||/||/||446||15.73||12|
A final aspect (important to me) is to use the right font size. I recommend using :
- the same font size as the rest of the document for the figure title, labels, legend and text boxes,
- 9/10 of the font size for the tick labels (numbers on axes).
You can notice that my advice on figures usually produce microscopic figures on your screen. It is quite bad, and I am not sure it would be wise to allow the position and paperposition to be decoupled again.
Do not worry, for the export will work out fine. You can (and should) also reduce the marker size also to achieve better consistency (size 3 and 4 work out fine). If you want to be convinced, please visit my dummy Overleaf document that puts these in practice. I also wrote a MATLAB script called "prettify" that applies all these tweaks to the current figure. Do not forget to enclose your math symbols in dollars ($) in your legend, your axis labels and your title !
Good PNG export quality
Once you completed all these modifications, you can just export your figure into PNG with a crazy high resolution, that you can specify this way.
print('-dpng', gcf, 'myfigure.png', '-r600');
The last argument being the resolution (you can see that 600 dpi is crazy for me -- you can go a lot higher).
Nice markers in PNG
I usually find myself a bit puzzled by the default aspect of filled markers in MATLAB. They look not very professional and have a "toy" aspect.
For line objects, the marker fill is done through the markerfacecolor attribute:
set(gco, 'markerfacecolor', [1 0.2 0.1]); % - gco is the currently active line % - colors are specified in RGB % format between 0 and 1
A good idea is to use a darker hue of the same color on the edge of the marker (which can be accessed through the markeredgecolor attribute) :
set(gco, 'markeredgecolor', 0.6*get(gco, 'markerfacecolor'));
I like the result more, especially for bright markers: