SetFigPaper

버전 1.0.3 (2.69 MB) 작성자: José M. Requena Plens
Function to modify the style of the graphical representations of MATLAB
다운로드 수: 238
업데이트 날짜: 2023/4/10

편집자 메모: This file was selected as MATLAB Central Pick of the Week

View SetFigPaper on File Exchange View SetFigPaper on Mathworks Blog Donate Donate

SetFigPaper

Introduction

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.

Examples

Grayscale

Example 1

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

Example 2

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

Interpreter

Example 1

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

Example 2

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

FontName

  • Only work with 'Tex' interpreter

Example 1

setfigpaper('FontName','Courier')

Code: https://www.mathworks.com/help/matlab/ref/wordcloud.html

Original setfigpaper

Example 2

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

FontSize

Example 1

setfigpaper('FontSize',6)

Code: https://www.mathworks.com/help/matlab/ref/parallelplot.html

Original setfigpaper

Example 2

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

LineWidth

Example 1

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

Example 2

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

Troubleshooting

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

Incompatibility Issues

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:

  • #f03c15 Fixed by version checking.
  • #efb810 It runs but doesn't affect.

MATLAB 2018b (9.5) and earlier

   Axes/Object Description Line code
#f03c15 Heatmap Unable to assign an interpreter to text within the map. set(ax.Heatmap,'Interpreter',type);
#f03c15 GraphPlot Cannot modify node font. set(grap,'nodefontname',...
#efb810 Polar Axes Grayscale cannot be applied to all elements.

Author

Jose M. Requena Plens, 2020. (info@jmrplens.com | joreple@upv.es)

Original concept: Noe Jimenez, 2014. (noe.jimenez@csic.es | nojigon@i3m.upv.es)

Donate Donate

인용 양식

Requena-Plens, Jose M. SetFigPaper (https://www.github.com/jmrplens/SetFigPaper), GitHub. 2020.

MATLAB 릴리스 호환 정보
개발 환경: R2020a
모든 릴리스와 호환
플랫폼 호환성
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!

GitHub 디폴트 브랜치를 사용하는 버전은 다운로드할 수 없음

버전 게시됨 릴리스 정보
1.0.3

Readme update

1.0.2

Fixed: The title in colorbar was not modified.
Added option: Apply to a specific figure.

1.0.1

Fix compatibility issues. If you find any error or the modification does not apply to any item, please inform me and I will try to solve it.

1.0.0

이 GitHub 애드온의 문제를 보거나 보고하려면 GitHub 리포지토리로 가십시오.
이 GitHub 애드온의 문제를 보거나 보고하려면 GitHub 리포지토리로 가십시오.