With this function it is possible to modify multiple style parameters of MATLAB graphic representations. It is only necessary to include the function call after the graphic representation code, that's all.
It can be used in two ways:
- Name-Value pair arguments:
setfigpaper('Width',[20,0.65],'Interpreter','Latex')
. Only the parameters you want to modify are necessary. - Only values:
setfigpaper([20,0.65],10,'Helvetica','Latex')
. With explicit order: (Width,FontSize,FontName,Interpreter,Grayscale,LineWidth,Figure).
The available options are:
Name | Description |
---|---|
Width |
Simple: one integer. With aspect ratio: array with two elements, the width and the aspect ratio. |
FontSize |
The font size in all texts in the figure. |
FontName |
Font family. |
Interpreter |
Text interpreter syntax, 'Latex', 'tex' or 'none'. If you don't want to modify the interpreter the value must be [] (empty value). |
Grayscale |
Change all colours to grayscale. [boolean] |
LineWidth |
Set line width only for axes, not for data. |
Figure |
Apply to a specific figure. |
setfigpaper('GrayScale',true)
Code: MathWorks Plot Gallery Team (2020). MATLAB Plot Gallery - Wind (https://www.mathworks.com/matlabcentral/fileexchange/35250-matlab-plot-gallery-wind), MATLAB Central File Exchange. Retrieved May 14, 2020.
Original | setfigpaper |
---|---|
setfigpaper('GrayScale',true)
Code: MathWorks Plot Gallery Team (2020). MATLAB Plot Gallery - Subplot (2) (https://www.mathworks.com/matlabcentral/fileexchange/35298-matlab-plot-gallery-subplot-2), MATLAB Central File Exchange. Retrieved May 14, 2020.
Original | setfigpaper |
---|---|
setfigpaper('Interpreter','Latex')
Code: MathWorks Plot Gallery Team (2020). MATLAB Plot Gallery - Heatmap Chart (https://www.mathworks.com/matlabcentral/fileexchange/63457-matlab-plot-gallery-heatmap-chart), MATLAB Central File Exchange. Retrieved May 14, 2020.
Original | setfigpaper |
---|---|
setfigpaper('Interpreter','Latex')
Code: MathWorks Plot Gallery Team (2020). MATLAB Plot Gallery - Line Plot 2D (2) (https://www.mathworks.com/matlabcentral/fileexchange/35256-matlab-plot-gallery-line-plot-2d-2), MATLAB Central File Exchange. Retrieved May 14, 2020.
Original | setfigpaper |
---|---|
- Only work with 'Tex' interpreter
setfigpaper('FontName','Courier')
Original | setfigpaper |
---|---|
setfigpaper('FontName','Times New Roman')
Code: MathWorks Plot Gallery Team (2020). MATLAB Plot Gallery - Heatmap Chart (https://www.mathworks.com/matlabcentral/fileexchange/63457-matlab-plot-gallery-heatmap-chart), MATLAB Central File Exchange. Retrieved May 14, 2020.
Original | setfigpaper |
---|---|
setfigpaper('FontSize',6)
Original | setfigpaper |
---|---|
setfigpaper('FontSize',15)
Code: MathWorks Plot Gallery Team (2020). MATLAB Plot Gallery - Directed Graph Plot (https://www.mathworks.com/matlabcentral/fileexchange/63456-matlab-plot-gallery-directed-graph-plot), MATLAB Central File Exchange. Retrieved May 14, 2020.
Original | setfigpaper |
---|---|
setfigpaper('LineWidth',2)
Code: MathWorks Plot Gallery Team (2020). MATLAB Plot Gallery - Set Axes Positions (https://www.mathworks.com/matlabcentral/fileexchange/63458-matlab-plot-gallery-set-axes-positions), MATLAB Central File Exchange. Retrieved May 14, 2020.
Original | setfigpaper |
---|---|
setfigpaper('LineWidth',1.5)
Code: MathWorks Plot Gallery Team (2020). MATLAB Plot Gallery - Scatter Plot 3D (https://www.mathworks.com/matlabcentral/fileexchange/35288-matlab-plot-gallery-scatter-plot-3d), MATLAB Central File Exchange. Retrieved May 14, 2020.
Original | setfigpaper |
---|---|
In some representations, it is necessary to carry out previous steps for the function to work correctly.
-
pie and pie3: If you use LaTeX interpreter with default labels (percentage) you need to fix the plot before call setfigpaper. Solution:
p = pie([1 3 0.5 2.5 2]); txt = findobj(p,'Type','Text'); arrayfun(@(x) set(x,'String',strrep(x.String,'%','\%')),txt,... 'UniformOutput',false) setfigpaper
-
pareto: If you use LaTeX interpreter with default ticklabels (percentage) you need to fix the plot before call setfigpaper. Solution:
[H,ax] = pareto([200 120 555 608], {'Fred','Ginger','Norman','Max'}); ax(2).YTickLabel = arrayfun(@(x) strrep(x,'%','\%'),ax(2).YTickLabel); setfigpaper
Setfigpaper is developed in MATLAB 2020. In some versions not all options are available. The function checks the version so that the incompatible code is not executed.
If you find any error or the modification does not apply to any item, please inform me and I will try to solve it.
Legend meaning:
Jose M. Requena Plens, 2020. ([email protected] | [email protected])
Original concept: Noe Jimenez, 2014. ([email protected] | [email protected])