├── GENERAL_INSTRUCTIONS.txt ├── PlottingTemplates ├── ColorsAndFonts │ ├── Font_Preview.jpg │ ├── MyColors_Quick.png │ ├── NunitoFontFiles │ │ ├── Nunito-Black.ttf │ │ ├── Nunito-BlackItalic.ttf │ │ ├── Nunito-Bold.ttf │ │ ├── Nunito-BoldItalic.ttf │ │ ├── Nunito-ExtraBold.ttf │ │ ├── Nunito-ExtraBoldItalic.ttf │ │ ├── Nunito-ExtraLight.ttf │ │ ├── Nunito-ExtraLightItalic.ttf │ │ ├── Nunito-Italic.ttf │ │ ├── Nunito-Light.ttf │ │ ├── Nunito-LightItalic.ttf │ │ ├── Nunito-Medium.ttf │ │ ├── Nunito-MediumItalic.ttf │ │ ├── Nunito-Regular.ttf │ │ ├── Nunito-SemiBold.ttf │ │ └── Nunito-SemiBoldItalic.ttf │ └── Palette_Detailed.png ├── Figures │ ├── PlottingTemplate_Advanced_big.png │ ├── PlottingTemplate_Advanced_small.png │ ├── PlottingTemplate_Detailed_big.png │ ├── PlottingTemplate_Detailed_small.png │ ├── PlottingTemplate_Quick_Separate.png │ ├── PlottingTemplate_Quick_big.png │ ├── PlottingTemplate_Quick_small.png │ └── ProfessionalPlots_Image.png ├── FontDownloadInstructions.txt ├── GENERAL_INSTRUCTIONS.txt ├── PlottingTemplate_Advanced.m ├── PlottingTemplate_Detailed.m ├── PlottingTemplate_Short.m └── STANDARDS │ ├── PLOT_STANDARDS.m │ ├── SAVE_MY_FIGURE.m │ └── STANDARDIZE_FIGURE.m └── README.md /GENERAL_INSTRUCTIONS.txt: -------------------------------------------------------------------------------- 1 | Add this folder to path in MATLAB. To do this follow the given steps: 2 | 3 | Open MATLAB -> Home -> Set Path -> Add with Subfolders -> Choose the above folder 'PlottingTemplates' 4 | 5 | You are ready to go! -------------------------------------------------------------------------------- /PlottingTemplates/ColorsAndFonts/Font_Preview.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atharvaaalok/MATLAB_Defaults/38d1730ae4f2ffbec3c0a176b10fd1953b91ba5d/PlottingTemplates/ColorsAndFonts/Font_Preview.jpg -------------------------------------------------------------------------------- /PlottingTemplates/ColorsAndFonts/MyColors_Quick.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atharvaaalok/MATLAB_Defaults/38d1730ae4f2ffbec3c0a176b10fd1953b91ba5d/PlottingTemplates/ColorsAndFonts/MyColors_Quick.png -------------------------------------------------------------------------------- /PlottingTemplates/ColorsAndFonts/NunitoFontFiles/Nunito-Black.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atharvaaalok/MATLAB_Defaults/38d1730ae4f2ffbec3c0a176b10fd1953b91ba5d/PlottingTemplates/ColorsAndFonts/NunitoFontFiles/Nunito-Black.ttf -------------------------------------------------------------------------------- /PlottingTemplates/ColorsAndFonts/NunitoFontFiles/Nunito-BlackItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atharvaaalok/MATLAB_Defaults/38d1730ae4f2ffbec3c0a176b10fd1953b91ba5d/PlottingTemplates/ColorsAndFonts/NunitoFontFiles/Nunito-BlackItalic.ttf -------------------------------------------------------------------------------- /PlottingTemplates/ColorsAndFonts/NunitoFontFiles/Nunito-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atharvaaalok/MATLAB_Defaults/38d1730ae4f2ffbec3c0a176b10fd1953b91ba5d/PlottingTemplates/ColorsAndFonts/NunitoFontFiles/Nunito-Bold.ttf -------------------------------------------------------------------------------- /PlottingTemplates/ColorsAndFonts/NunitoFontFiles/Nunito-BoldItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atharvaaalok/MATLAB_Defaults/38d1730ae4f2ffbec3c0a176b10fd1953b91ba5d/PlottingTemplates/ColorsAndFonts/NunitoFontFiles/Nunito-BoldItalic.ttf -------------------------------------------------------------------------------- /PlottingTemplates/ColorsAndFonts/NunitoFontFiles/Nunito-ExtraBold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atharvaaalok/MATLAB_Defaults/38d1730ae4f2ffbec3c0a176b10fd1953b91ba5d/PlottingTemplates/ColorsAndFonts/NunitoFontFiles/Nunito-ExtraBold.ttf -------------------------------------------------------------------------------- /PlottingTemplates/ColorsAndFonts/NunitoFontFiles/Nunito-ExtraBoldItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atharvaaalok/MATLAB_Defaults/38d1730ae4f2ffbec3c0a176b10fd1953b91ba5d/PlottingTemplates/ColorsAndFonts/NunitoFontFiles/Nunito-ExtraBoldItalic.ttf -------------------------------------------------------------------------------- /PlottingTemplates/ColorsAndFonts/NunitoFontFiles/Nunito-ExtraLight.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atharvaaalok/MATLAB_Defaults/38d1730ae4f2ffbec3c0a176b10fd1953b91ba5d/PlottingTemplates/ColorsAndFonts/NunitoFontFiles/Nunito-ExtraLight.ttf -------------------------------------------------------------------------------- /PlottingTemplates/ColorsAndFonts/NunitoFontFiles/Nunito-ExtraLightItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atharvaaalok/MATLAB_Defaults/38d1730ae4f2ffbec3c0a176b10fd1953b91ba5d/PlottingTemplates/ColorsAndFonts/NunitoFontFiles/Nunito-ExtraLightItalic.ttf -------------------------------------------------------------------------------- /PlottingTemplates/ColorsAndFonts/NunitoFontFiles/Nunito-Italic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atharvaaalok/MATLAB_Defaults/38d1730ae4f2ffbec3c0a176b10fd1953b91ba5d/PlottingTemplates/ColorsAndFonts/NunitoFontFiles/Nunito-Italic.ttf -------------------------------------------------------------------------------- /PlottingTemplates/ColorsAndFonts/NunitoFontFiles/Nunito-Light.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atharvaaalok/MATLAB_Defaults/38d1730ae4f2ffbec3c0a176b10fd1953b91ba5d/PlottingTemplates/ColorsAndFonts/NunitoFontFiles/Nunito-Light.ttf -------------------------------------------------------------------------------- /PlottingTemplates/ColorsAndFonts/NunitoFontFiles/Nunito-LightItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atharvaaalok/MATLAB_Defaults/38d1730ae4f2ffbec3c0a176b10fd1953b91ba5d/PlottingTemplates/ColorsAndFonts/NunitoFontFiles/Nunito-LightItalic.ttf -------------------------------------------------------------------------------- /PlottingTemplates/ColorsAndFonts/NunitoFontFiles/Nunito-Medium.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atharvaaalok/MATLAB_Defaults/38d1730ae4f2ffbec3c0a176b10fd1953b91ba5d/PlottingTemplates/ColorsAndFonts/NunitoFontFiles/Nunito-Medium.ttf -------------------------------------------------------------------------------- /PlottingTemplates/ColorsAndFonts/NunitoFontFiles/Nunito-MediumItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atharvaaalok/MATLAB_Defaults/38d1730ae4f2ffbec3c0a176b10fd1953b91ba5d/PlottingTemplates/ColorsAndFonts/NunitoFontFiles/Nunito-MediumItalic.ttf -------------------------------------------------------------------------------- /PlottingTemplates/ColorsAndFonts/NunitoFontFiles/Nunito-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atharvaaalok/MATLAB_Defaults/38d1730ae4f2ffbec3c0a176b10fd1953b91ba5d/PlottingTemplates/ColorsAndFonts/NunitoFontFiles/Nunito-Regular.ttf -------------------------------------------------------------------------------- /PlottingTemplates/ColorsAndFonts/NunitoFontFiles/Nunito-SemiBold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atharvaaalok/MATLAB_Defaults/38d1730ae4f2ffbec3c0a176b10fd1953b91ba5d/PlottingTemplates/ColorsAndFonts/NunitoFontFiles/Nunito-SemiBold.ttf -------------------------------------------------------------------------------- /PlottingTemplates/ColorsAndFonts/NunitoFontFiles/Nunito-SemiBoldItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atharvaaalok/MATLAB_Defaults/38d1730ae4f2ffbec3c0a176b10fd1953b91ba5d/PlottingTemplates/ColorsAndFonts/NunitoFontFiles/Nunito-SemiBoldItalic.ttf -------------------------------------------------------------------------------- /PlottingTemplates/ColorsAndFonts/Palette_Detailed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atharvaaalok/MATLAB_Defaults/38d1730ae4f2ffbec3c0a176b10fd1953b91ba5d/PlottingTemplates/ColorsAndFonts/Palette_Detailed.png -------------------------------------------------------------------------------- /PlottingTemplates/Figures/PlottingTemplate_Advanced_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atharvaaalok/MATLAB_Defaults/38d1730ae4f2ffbec3c0a176b10fd1953b91ba5d/PlottingTemplates/Figures/PlottingTemplate_Advanced_big.png -------------------------------------------------------------------------------- /PlottingTemplates/Figures/PlottingTemplate_Advanced_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atharvaaalok/MATLAB_Defaults/38d1730ae4f2ffbec3c0a176b10fd1953b91ba5d/PlottingTemplates/Figures/PlottingTemplate_Advanced_small.png -------------------------------------------------------------------------------- /PlottingTemplates/Figures/PlottingTemplate_Detailed_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atharvaaalok/MATLAB_Defaults/38d1730ae4f2ffbec3c0a176b10fd1953b91ba5d/PlottingTemplates/Figures/PlottingTemplate_Detailed_big.png -------------------------------------------------------------------------------- /PlottingTemplates/Figures/PlottingTemplate_Detailed_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atharvaaalok/MATLAB_Defaults/38d1730ae4f2ffbec3c0a176b10fd1953b91ba5d/PlottingTemplates/Figures/PlottingTemplate_Detailed_small.png -------------------------------------------------------------------------------- /PlottingTemplates/Figures/PlottingTemplate_Quick_Separate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atharvaaalok/MATLAB_Defaults/38d1730ae4f2ffbec3c0a176b10fd1953b91ba5d/PlottingTemplates/Figures/PlottingTemplate_Quick_Separate.png -------------------------------------------------------------------------------- /PlottingTemplates/Figures/PlottingTemplate_Quick_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atharvaaalok/MATLAB_Defaults/38d1730ae4f2ffbec3c0a176b10fd1953b91ba5d/PlottingTemplates/Figures/PlottingTemplate_Quick_big.png -------------------------------------------------------------------------------- /PlottingTemplates/Figures/PlottingTemplate_Quick_small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atharvaaalok/MATLAB_Defaults/38d1730ae4f2ffbec3c0a176b10fd1953b91ba5d/PlottingTemplates/Figures/PlottingTemplate_Quick_small.png -------------------------------------------------------------------------------- /PlottingTemplates/Figures/ProfessionalPlots_Image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/atharvaaalok/MATLAB_Defaults/38d1730ae4f2ffbec3c0a176b10fd1953b91ba5d/PlottingTemplates/Figures/ProfessionalPlots_Image.png -------------------------------------------------------------------------------- /PlottingTemplates/FontDownloadInstructions.txt: -------------------------------------------------------------------------------- 1 | The toolbox uses Nunito as the font for plotting. 2 | 3 | To check if your matlab version has it installed run the following lines in your command window: 4 | >> d = listfonts 5 | 6 | If your system does not have the font then follow these simple steps to download/install it: 7 | 1) Download from google fonts here: https://fonts.google.com/specimen/Nunito?query=nunito 8 | OR 9 | 2) Use the fonts I have provided in the ColorsAndFonts/NunitoFonts folder 10 | Copy the provided .ttf files and save in the following location: 11 | C:\Program Files\MATLAB\R2022a\sys\java\jre\win64\jre\lib\fonts 12 | Then right click each file and choose open with "Windows Font Viewer". Then choose the install option available on the top. 13 | 14 | // This feature is under development: 15 | You can use any font for your figures. To do this simply download the corresponding .ttf files for that font and follow the steps as explained in 2). 16 | 17 | 18 | Re-run matlab and you are ready to go!!! 19 | -------------------------------------------------------------------------------- /PlottingTemplates/GENERAL_INSTRUCTIONS.txt: -------------------------------------------------------------------------------- 1 | If you downloaded the Zip version from the internet then you need to follow these steps to add the toolbox files to path: 2 | 3 | Add this folder to path in MATLAB. To do this follow the given steps: 4 | Open MATLAB -> Home -> Set Path -> Add with Subfolders -> Choose the above folder 'PlottingTemplates' 5 | 6 | OR 7 | Go to Add-ons on Matlab and add directly through their. It will take care of adding it to path. 8 | 9 | You are ready to go! -------------------------------------------------------------------------------- /PlottingTemplates/PlottingTemplate_Advanced.m: -------------------------------------------------------------------------------- 1 | % INITIAL HOUSE-KEEPING STUFF 2 | 3 | % clear->erase workspace variables, clc->clean command window, close all-> close all currently open figures 4 | clear; clc; close all; 5 | 6 | % The following file has useful defaults for: Font, Colors etc. 7 | % Have a look at this file. You can customize it according to your needs. 8 | PS = PLOT_STANDARDS(); 9 | 10 | %======================================================== 11 | % GENERATE DATA TO PLOT 12 | 13 | % To make an example scatter plot we generate scatter data using a random matrix. We create a 20x20 random matrix 14 | randmatrix = rand(20,20); 15 | % Organize that 20x20 matrix in a column vector. Now we have a vector of 400 random numbers. 16 | randmatrix = randmatrix(:); 17 | % We take first 200 entries to be x-coordinates and the next 200 as y-coordinates of data points on the plane 18 | x1 = randmatrix(1:end/2); 19 | y1 = randmatrix(end/2 + 1:end); 20 | % We also generate data for plotting y = x^2 21 | x2 = linspace(0, 1, 100); 22 | y2 = x2.^2; 23 | % We copy the above two to create 2 more data sets. 24 | % y3 same as y1 25 | x3 = x1; 26 | y3 = y1; 27 | % y4 same as y2 28 | x4 = x2; 29 | y4 = y2; 30 | 31 | 32 | %======================================================== 33 | % STEPS FOR PLOTTING 34 | 35 | % Create a figure. Each 'figure' is a new window which opens up. So number them properly 36 | figure(1); 37 | % Get the handle of figure(n). 38 | fig1_comps.fig = gcf; 39 | % We create a 2x2 tile set 40 | fig1_comps.t1 = tiledlayout(fig1_comps.fig, 2, 2); 41 | % When the number of tiles is unknown use - tiledlayout(fig1, 'flow'); 42 | 43 | 44 | % For each data set that you plot number the plot. 45 | % Each figure is a new window on which we can plot many data sets. Eg: In the same window plot a line y = mx + c and y = x^2 as well. 46 | 47 | % Tile 1 48 | fig1_comps.n(1) = nexttile; 49 | fig1_comps.p1 = plot(x1, y1, 'o'); 50 | fig1_comps.tile1.plotXLabel = xlabel('hey bro'); 51 | legend(fig1_comps.p1, 'Scatter'); 52 | 53 | % Tile 2 54 | fig1_comps.n(2) = nexttile; 55 | fig1_comps.p2 = plot(x2, y2); 56 | legend(fig1_comps.p2, '$$y = x^{2}$$'); 57 | 58 | % Tile 3 59 | fig1_comps.n(3) = nexttile; 60 | fig1_comps.p3 = plot(x3, y3, 'o'); 61 | legend(fig1_comps.p3, 'Scatter'); 62 | 63 | % Tile 4 64 | fig1_comps.n(4) = nexttile; 65 | fig1_comps.p4 = plot(x4, y4); 66 | % set(gca, 'yticklabel', []); 67 | legend(fig1_comps.p4, '$$y = x^{2}$$'); 68 | 69 | 70 | %======================================================== 71 | % ADD LABELS, LEGEND AND SPECIFY SPACING AND PADDING 72 | 73 | % Add Global Labels and Title 74 | fig1_comps.t1.Title.String = 'Tile Global Title'; 75 | fig1_comps.t1.XLabel.String = 'Tile Global X Label'; 76 | fig1_comps.t1.YLabel.String = 'Tile Global Y Label'; 77 | 78 | % Add Legend. Use LaTeX format to add equations. Enclose in $$ LaTeX code $$ 79 | % NOTE: The default interpretor has been set to LaTeX so all LaTeX equations should work 80 | 81 | % Padding, Spacing and x-axis label removal 82 | fig1_comps.t1.Padding = 'tight'; 83 | set(gca, 'yticklabel', []); % Removes yticklabels for the current axis. Use as in Tile 4 to remove for each individual tile. 84 | fig1_comps.t1.TileSpacing = 'none'; 85 | 86 | 87 | %======================================================== 88 | % INSTANTLY IMPROVE AESTHETICS 89 | 90 | % Set default properties for fign 91 | STANDARDIZE_FIGURE(fig1_comps); 92 | 93 | 94 | %======================================================== 95 | % SET PLOT PROPERTIES 96 | 97 | % The following command will set the properties for p1. 98 | % Choices for Colors can be found in in PLOT_STANDARDS 99 | set(fig1_comps.p1, 'LineStyle', 'none', 'Marker', 'o', 'MarkerSize', 6, 'MarkerEdgeColor', PS.Blue4, 'MarkerFaceColor', PS.Blue1); 100 | set(fig1_comps.p2, 'LineStyle', '--', 'LineWidth', 2, 'Color', PS.Red2); 101 | set(fig1_comps.p3, 'LineStyle', 'none', 'Marker', 'o', 'MarkerSize', 6, 'MarkerEdgeColor', PS.Blue4, 'MarkerFaceColor', PS.Blue1); 102 | set(fig1_comps.p4, 'LineStyle', '--', 'LineWidth', 2, 'Color', PS.Red2); 103 | 104 | 105 | %======================================================== 106 | % ADD TEXT ON THE PLOT 107 | 108 | % Choose position of text 109 | xpos = .3; 110 | ypos = .3; 111 | % Set text properties 112 | plotText1 = text(xpos, ypos, 'Hello1$$\pi$$', 'Interpreter', 'latex', 'Color', PS.MyBlack, 'FontSize', PS.PlotTextFontSize); 113 | plotText2 = text(xpos + .3, ypos + .3, 'Hello2', 'Interpreter', 'latex', 'Color', PS.MyBlack, 'FontSize', PS.PlotTextFontSize); 114 | 115 | 116 | %======================================================== 117 | % SAVE A PARTICULAR FIGURE AS AN IMAGE 118 | 119 | % Save fign 120 | SAVE_MY_FIGURE(fig1_comps, 'Figures/PlottingTemplate_Advanced_small.png', 'small'); 121 | SAVE_MY_FIGURE(fig1_comps, 'Figures/PlottingTemplate_Advanced_big.png', 'big'); 122 | 123 | 124 | 125 | %======================================================== 126 | % HOW TO CITE THIS TOOLBOX? (Please support :) ) 127 | % Refer - https://in.mathworks.com/matlabcentral/answers/1575908-how-to-cite-matlab-file-exchange-file-using-bibtex?s_tid=es_ans_avr_ans_view#answers_list 128 | % OR 129 | % Include the following in your LaTeX .bib file: 130 | % @misc 131 | % { atharva2021, 132 | % author = {Atharva Aalok}, 133 | % title = {Professional Plots}, 134 | % year = 2021 135 | % howpublished = "\url{https://www.mathworks.com/matlabcentral/fileexchange/100766-professional_plots}", 136 | % note = "[Online; accessed October 31, 202]" 137 | % } 138 | 139 | 140 | % PLEASE SUPPORT ME BY CITING THIS TOOLBOX. THANK YOU!!! -------------------------------------------------------------------------------- /PlottingTemplates/PlottingTemplate_Detailed.m: -------------------------------------------------------------------------------- 1 | % INITIAL HOUSE-KEEPING STUFF 2 | 3 | % clear->erase workspace variables, clc->clean command window, close all-> close all currently open figures 4 | clear; clc; close all; 5 | 6 | % The following file has useful defaults for: Font, Colors etc. 7 | % Have a look at this file. You can customize it according to your needs. 8 | PS = PLOT_STANDARDS(); 9 | 10 | %======================================================== 11 | % GENERATE DATA TO PLOT 12 | 13 | % Create variable 14 | total_data_points = 70; 15 | x = linspace(0, pi, total_data_points); 16 | % Generate functions 17 | y1 = sin(x); 18 | y2 = cos(x); 19 | y3 = (x/pi); 20 | y4 = (x/pi).^2; 21 | y5 = exp(x/pi); 22 | y6 = log(1+x); 23 | 24 | 25 | %======================================================== 26 | % CREATE FIGURE AND PLOTS 27 | 28 | figure(1); 29 | fig1_comps.fig = gcf; 30 | hold on 31 | fig1_comps.p1 = plot(x, y1); 32 | fig1_comps.p2 = line(x, y2); 33 | fig1_comps.p3 = plot(x, y3); 34 | fig1_comps.p4 = plot(x, y4); 35 | fig1_comps.p5 = plot(x, y5); 36 | fig1_comps.p6 = plot(x, y6); 37 | % Create semitransparent area plots 38 | fig1_comps.p7 = area(x, y4); 39 | 40 | % grid on 41 | 42 | 43 | %======================================================== 44 | % ADJUST LINE PROPERTIES (FUNCTIONAL + AESTHETICS) 45 | 46 | set(fig1_comps.p1, 'Color', PS.Blue1, 'LineWidth', 2); 47 | set(fig1_comps.p2, 'LineStyle', 'none', 'Marker', '.', 'MarkerSize', 8, 'MarkerEdgeColor', PS.Green3, 'MarkerFaceColor', PS.Green3); 48 | set(fig1_comps.p3, 'LineStyle', '--', 'Color', PS.Red3, 'LineWidth', 2); 49 | set(fig1_comps.p4, 'LineStyle', '-.', 'Color', PS.Orange2, 'LineWidth', 2); 50 | set(fig1_comps.p5, 'LineStyle', 'none', 'Marker', 'o', 'MarkerSize', 4, 'MarkerEdgeColor', PS.MyBlack, 'MarkerFaceColor', PS.Grey1); 51 | set(fig1_comps.p6, 'LineStyle', 'none', 'Marker', 'x', 'LineWidth', 1, 'Color', PS.Blue4, 'MarkerSize', 4, 'MarkerEdgeColor', PS.Blue4, 'MarkerFaceColor', PS.Blue4); 52 | % area plot properties - alpha sets the transparency 53 | set(fig1_comps.p7, 'FaceColor', PS.Yellow2, 'FaceAlpha', .3, 'EdgeAlpha', 0); 54 | 55 | 56 | %======================================================== 57 | % ADD LABELS 58 | 59 | fig1_comps.plotTitle = title('Template for Beautiful Plots'); 60 | fig1_comps.plotXLabel = xlabel('x axis data'); 61 | fig1_comps.plotYLabel = ylabel('y axis data'); 62 | 63 | % Rotate Label 64 | % Change axis properties 65 | ax = gca; 66 | ax.YLabel.Rotation = 60; 67 | 68 | % Label Position 69 | axes_handle = gca; 70 | axes_handle.XLabel.Position = [1.7500, -1.260, -1.0000]; 71 | axes_handle.YLabel.Position = [-0.2608, 1.5000, -1.0000]; 72 | 73 | 74 | %======================================================== 75 | % ADD LEGEND 76 | 77 | % (For LaTeX add -> ,'Interpreter','latex'), use $$ latex $$ for larger font 78 | % size 79 | fig1_comps.plotLegend = legend([fig1_comps.p1, fig1_comps.p2, fig1_comps.p3, ... 80 | fig1_comps.p4, fig1_comps.p5, fig1_comps.p6, fig1_comps.p7], '$$sin(x)$$', '$$cos(x)$$', ... 81 | '$$\frac{x}{\pi}$$', '\Big($$\frac{x}{\pi}\Big)^2$$', ... 82 | '$$exp\Big({\frac{x}{\pi}}\Big)$$', '$$log(1+x)$$', ... 83 | 'Area\Big($$\frac{x}{\pi}\Big)^2$$', 'Interpreter', 'latex'); 84 | % Legend Properties 85 | legendX0 = .7; legendY0 = .08; legendWidth = .3; legendHeight = .3; 86 | set(fig1_comps.plotLegend, 'position', [legendX0, legendY0, legendWidth, ... 87 | legendHeight], 'Box', 'on'); 88 | set(fig1_comps.plotLegend, 'FontSize', PS.LegendFontSize, 'LineWidth', 1.5, ... 89 | 'EdgeColor', PS.Red4); 90 | 91 | 92 | %======================================================== 93 | % ADD TEXT ON THE PLOT 94 | 95 | num1 = 2; 96 | num2 = 10; 97 | % set position of the text 98 | xpos = .5; 99 | ypos = 2.5; 100 | % here we put 2 backslash \\pi, to espcape the backslash and interpret it 101 | % as for literal character 102 | text_string = sprintf('What a Beautiful Plot! $$\\frac{x}{\\pi}$$ num1 = %d, num2 = %d', num1, num2); 103 | fig1_comps.plotText = text(xpos, ypos, text_string, 'Interpreter', 'latex', 'Color', PS.MyBlack, 'FontSize', 50); 104 | 105 | 106 | %======================================================== 107 | % ADJUST FONT 108 | 109 | set(gca, 'FontName', PS.DefaultFont, 'FontWeight', 'bold'); 110 | set([fig1_comps.plotTitle, fig1_comps.plotXLabel, fig1_comps.plotYLabel], 'FontName', PS.DefaultFont); 111 | set(fig1_comps.plotText, 'FontName', PS.DefaultFont); 112 | set(gca, 'FontSize', PS.AxisNumbersFontSize); 113 | set([fig1_comps.plotXLabel, fig1_comps.plotYLabel], 'FontSize', PS.AxisFontSize); 114 | set(fig1_comps.plotText, 'FontSize', PS.AxisFontSize); 115 | set(fig1_comps.plotTitle, 'FontSize', PS.TitleFontSize, 'FontWeight' , 'bold'); 116 | 117 | 118 | %======================================================== 119 | % ADJUST AXES PROPERTIES 120 | 121 | set(gca, 'Box', 'on', 'TickDir', 'out', 'TickLength', [.01 .01], ... 122 | 'XMinorTick', 'on', 'YMinorTick', 'on', 'YGrid', 'off', ... 123 | 'XColor', [.3 .3 .3], 'YColor', [.3 .3 .3], 'YTick', 0:1:25, ... 124 | 'LineWidth', 1.5); 125 | % Change axis properties 126 | ax = gca; 127 | ax.XAxis.Limits = [min(x), max(x)]; 128 | % ax.XAxis.TickValues = x(1:1:end); 129 | ax.XAxis.TickLabelRotation = 30; 130 | ax.XAxis.FontWeight = 'bold'; 131 | ax.XAxis.FontAngle = 'italic'; 132 | ax.YAxis.TickLabelFormat = '$%,.0fM'; 133 | % Set the axes to go through the origin 134 | set(gca,'XAxisLocation', 'bottom', 'YAxisLocation', 'left'); 135 | 136 | 137 | %======================================================== 138 | % ANNOTATION 139 | 140 | % merged arrow 141 | drawArrow = annotation('arrow', 'Color', PS.Blue1, 'LineWidth', 2); 142 | drawArrow.Parent = gca; 143 | drawArrow.X = [x(40) x(43)]; 144 | drawArrow.Y = [y1(40) y1(43)]; 145 | % non merged arrow 146 | drawArrow = annotation('arrow', 'Color', PS.Blue3, 'LineWidth', 2); 147 | drawArrow.Parent = gca; 148 | drawArrow.X = [x(30) x(33)]; 149 | drawArrow.Y = [y1(30) y1(33)]; 150 | 151 | 152 | %======================================================== 153 | % SET FIGURE POSITION ON SCREEN AND THE SIZE 154 | % First 2 set (x,y) of figure. Last 2 set size of figure window 155 | % If this is not set then a default size is set. 156 | fig1_comps.fig.Position = [100, 100, 800, 600]; 157 | 158 | 159 | %======================================================== 160 | % SAVE A PARTICULAR FIGURE AS AN IMAGE 161 | 162 | % Save fign 163 | SAVE_MY_FIGURE(fig1_comps, 'Figures/PlottingTemplate_Detailed_small.png', 'small'); 164 | % SAVE_MY_FIGURE(fig1_comps, 'Figures/PlottingTemplate_Detailed_big.png', 'big'); 165 | 166 | 167 | %======================================================== 168 | % HOW TO CITE THIS TOOLBOX? (Please support :) ) 169 | % Refer - https://in.mathworks.com/matlabcentral/answers/1575908-how-to-cite-matlab-file-exchange-file-using-bibtex?s_tid=es_ans_avr_ans_view#answers_list 170 | % OR 171 | % Include the following in your LaTeX .bib file: 172 | % @misc 173 | % { atharva2021, 174 | % author = {Atharva Aalok}, 175 | % title = {Professional Plots}, 176 | % year = 2021 177 | % howpublished = "\url{https://www.mathworks.com/matlabcentral/fileexchange/100766-professional_plots}", 178 | % note = "[Online; accessed October 31, 202]" 179 | % } 180 | 181 | 182 | % PLEASE SUPPORT ME BY CITING THIS TOOLBOX. THANK YOU!!! -------------------------------------------------------------------------------- /PlottingTemplates/PlottingTemplate_Short.m: -------------------------------------------------------------------------------- 1 | % clear->clean workspace, clc->clean command window, close all-> close all currently open figures 2 | clear; clc; close all; 3 | % The standard values for colors saved in PLOT_STANDARDS() will be accessed from the variable PS 4 | PS = PLOT_STANDARDS(); 5 | %======================================================== 6 | % GENERATE DATA TO PLOT 7 | x1 = rand(1, 200); 8 | y1 = rand(1, 200); 9 | x2 = linspace(0, 1, 100); 10 | y2 = x2.^2; 11 | 12 | %======================================================== 13 | % STEPS FOR PLOTTING 14 | figure(1); 15 | fig1_comps.fig = gcf; 16 | hold on 17 | 18 | fig1_comps.p1 = plot(x1, y1, 'o'); 19 | fig1_comps.p2 = plot(x2, y2); 20 | hold off 21 | 22 | 23 | %======================================================== 24 | % ADD LABELS, TITLE, LEGEND 25 | title('Random Scatter Data'); 26 | xlabel('x axis Data'); 27 | ylabel('y axis Data'); 28 | 29 | legend([fig1_comps.p1, fig1_comps.p2], 'Scatter', '$$y = x^{2}$$'); 30 | legendX = .82; legendY = .87; legendWidth = 0.02; legendHeight = 0.02; 31 | fig1_comps.legendPosition = [legendX, legendY, legendWidth, legendHeight]; 32 | % If you want the tightest box set width and height values very low matlab automatically sets the tightest box 33 | 34 | %======================================================== 35 | % SET PLOT PROPERTIES 36 | % Choices for COLORS can be found in ColorPalette.png 37 | set(fig1_comps.p1, 'LineStyle', 'none', 'LineWidth', 1, 'Marker', 'o', 'MarkerSize', 6, 'MarkerFaceColor', PS.Blue1, 'MarkerEdgeColor', PS.Blue3); 38 | set(fig1_comps.p2, 'LineStyle', '--', 'LineWidth', 2, 'Color', PS.MyRed); 39 | 40 | %======================================================== 41 | % INSTANTLY IMPROVE AESTHETICS-most important step 42 | STANDARDIZE_FIGURE(fig1_comps); 43 | 44 | %======================================================== 45 | % SAVE FIGURE AS AN IMAGE: SAVE_MY_FIGURE(fig1_comps, 'Myfigure.png', 'small'); 46 | SAVE_MY_FIGURE(fig1_comps, 'Figures/PlottingTemplate_Quick_big.png', 'big'); 47 | SAVE_MY_FIGURE(fig1_comps, 'Figures/PlottingTemplate_Quick_small.png', 'small'); 48 | 49 | % Or if you do not like the default settings used to save the figure 50 | % Step1: Set the properties of your figure 51 | % Step2: Maybe move around the legend location manually on the figure that opens up. Then save or 52 | % Step3: Use the following code 53 | figure_resolution = 600; 54 | fig_filename = 'Figures/PlottingTemplate_Quick_Separate.png'; 55 | exportgraphics(fig1_comps.fig, fig_filename, 'Resolution', figure_resolution); 56 | 57 | 58 | %======================================================== 59 | % HOW TO CITE THIS TOOLBOX? (Please support :) ) 60 | % Refer - https://in.mathworks.com/matlabcentral/answers/1575908-how-to-cite-matlab-file-exchange-file-using-bibtex?s_tid=es_ans_avr_ans_view#answers_list 61 | % OR 62 | % Include the following in your LaTeX .bib file: 63 | % @misc 64 | % { atharva2021, 65 | % author = {Atharva Aalok}, 66 | % title = {Professional Plots}, 67 | % year = 2021 68 | % howpublished = "\url{https://www.mathworks.com/matlabcentral/fileexchange/100766-professional_plots}", 69 | % note = "[Online; accessed October 31, 2022]" 70 | % } 71 | 72 | 73 | % PLEASE SUPPORT ME BY CITING THIS TOOLBOX. THANK YOU!!! 74 | 75 | 76 | 77 | 78 | 79 | -------------------------------------------------------------------------------- /PlottingTemplates/STANDARDS/PLOT_STANDARDS.m: -------------------------------------------------------------------------------- 1 | function PS = PLOT_STANDARDS() 2 | 3 | % REFERENCE FOR STANDARD VALUES OF: 4 | % Font styles and sizes 5 | % Colors 6 | % Linestyles, MarkerStyles 7 | 8 | 9 | %======================================================== 10 | % FONTS 11 | 12 | % My STANDARD Font for Plots 13 | % To check which fonts are available use - d = listfonts 14 | 15 | d = listfonts; 16 | 17 | if any(strcmp(d, 'Nunito')) 18 | PS.DefaultFont = 'Nunito Light'; 19 | PS.AxisNumbersFontName = 'Nunito Light'; 20 | PS.AxisFont = 'Nunito Light'; 21 | PS.LegendFont = 'Nunito Light'; 22 | PS.TitleFont = 'Nunito Light'; 23 | PS.PlotTextFont = 'Nunito Light'; 24 | else 25 | PS.DefaultFont = 'Yu Mincho'; 26 | PS.AxisNumbersFontName = 'Yu Mincho'; 27 | PS.AxisFont = 'Yu Mincho'; 28 | PS.LegendFont = 'Yu Mincho'; 29 | PS.TitleFont = 'Yu Mincho'; 30 | PS.PlotTextFont = 'Yu Mincho'; 31 | end 32 | 33 | PS.DefaultFont = 'Yu Mincho'; 34 | PS.AxisNumbersFontName = 'Yu Mincho'; 35 | PS.AxisFont = 'Yu Mincho'; 36 | PS.LegendFont = 'Yu Mincho'; 37 | PS.TitleFont = 'Yu Mincho'; 38 | PS.PlotTextFont = 'Yu Mincho'; 39 | 40 | 41 | % Font size properties 42 | PS.TitleFontSize = 28; 43 | PS.LegendFontSize = 20; 44 | PS.AxisFontSize = 24; 45 | PS.PlotTextFontSize = 20; 46 | PS.AxisNumbersFontSize = 18; 47 | 48 | 49 | % Tiled Properties 50 | PS.Tiled.Global.TitleFontSize = 10; 51 | PS.Tiled.Global.AxisFontSize = 10; 52 | 53 | PS.Tiled.SubPlot.TitleFontSize = 20; 54 | PS.Tiled.SubPlot.LegendFontSize = 9; 55 | PS.Tiled.SubPlot.AxisFontSize = 9; 56 | PS.Tiled.SubPlot.PlotTextFontSize = 9; 57 | PS.Tiled.SubPlot.AxisNumbersFontSize = 9; 58 | 59 | 60 | 61 | %======================================================== 62 | % COLORS 63 | 64 | % Hex Color Palette 65 | % https://htmlcolorcodes.com/ 66 | % Some STANDARD color choices 67 | 68 | % QUICK COLOR PALATTE 69 | PS.MyYellow = [223, 255, 0]./255; 70 | PS.MyOrange = [255, 191, 0]./255; 71 | PS.MyPink = [222, 49, 99]./255; 72 | PS.MyRed = [255, 69, 0]./255; 73 | 74 | PS.MyBlue1 = [204, 204, 255]./255; 75 | PS.MyBlue2 = [0, 191, 255]./255; 76 | PS.MyBlue3 = [100, 149, 237]./255; 77 | PS.MyBlue4 = [65, 105, 225]./255; 78 | 79 | PS.MyGreen1 = [0, 255, 127]./255; 80 | PS.MyGreen2 = [124, 252, 0]./255; 81 | PS.MyGreen3 = [50, 205, 50]./255; 82 | PS.MyGreen4 = [0, 139, 139]./255; 83 | 84 | PS.MyWhite = [255, 255, 255]./255; 85 | PS.MyGrey1 = [169, 169, 169]./255; 86 | PS.MyGrey2 = [128, 128, 128]./255; 87 | PS.MyBlack = [0, 0, 0]./255; 88 | 89 | 90 | % DETAILED COLOR PALETTE 91 | PS.DRed1 = [205, 97, 85]./255; 92 | PS.DRed2 = [192, 57, 43]./255; 93 | PS.DRed3 = [169, 50, 38]./255; 94 | PS.DRed4 = [146, 43, 33]./255; 95 | PS.DRed5 = [123, 36, 28]./255; 96 | 97 | PS.Red1 = [236, 112, 99]./255; 98 | PS.Red2 = [231, 76, 60]./255; 99 | PS.Red3 = [203, 67, 53]./255; 100 | PS.Red4 = [176, 58, 46]./255; 101 | PS.Red5 = [120, 40, 31]./255; 102 | 103 | PS.DBlue1 = [165, 105, 189]./255; 104 | PS.DBlue2 = [142, 68, 173]./255; 105 | PS.DBlue3 = [125, 60, 152]./255; 106 | PS.DBlue4 = [91, 44, 111]./255; 107 | PS.DBlue5 = [74, 35, 90]./255; 108 | 109 | PS.Blue1 = [133, 193, 233]./255; 110 | PS.Blue2 = [93, 173, 226]./255; 111 | PS.Blue3 = [52, 152, 219]./255; 112 | PS.Blue4 = [40, 116, 166]./255; 113 | PS.Blue5 = [27, 79, 114]./255; 114 | 115 | PS.DGreen1 = [69, 179, 157]./255; 116 | PS.DGreen2 = [19, 141, 117]./255; 117 | PS.DGreen3 = [17, 122, 101]./255; 118 | PS.DGreen4 = [14, 102, 85]./255; 119 | PS.DGreen5 = [11, 83, 69]./255; 120 | 121 | PS.Green1 = [82, 190, 128]./255; 122 | PS.Green2 = [39, 174, 96]./255; 123 | PS.Green3 = [34, 153, 84]./255; 124 | PS.Green4 = [30, 132, 73]./255; 125 | PS.Green5 = [20, 90, 50]./255; 126 | 127 | PS.LGreen1 = [88, 214, 141]./255; 128 | PS.LGreen2 = [46, 204, 113]./255; 129 | PS.LGreen3 = [40, 180, 99]./255; 130 | PS.LGreen4 = [35, 155, 86]./255; 131 | PS.LGreen5 = [24, 106, 59]./255; 132 | 133 | PS.Yellow1 = [255, 244, 79]./255; 134 | PS.Yellow2 = [223, 255, 0]./255; 135 | PS.Yellow3 = [255, 239, 0]./255; 136 | PS.Yellow4 = [255, 223, 0]./255; 137 | PS.Yellow5 = [244, 196, 48]./255; 138 | 139 | PS.DYellow1 = [247, 220, 111]./255; 140 | PS.DYellow2 = [244, 208, 63]./255; 141 | PS.DYellow3 = [241, 196, 15]./255; 142 | PS.DYellow4 = [212, 172, 13]./255; 143 | PS.DYellow5 = [183, 149, 11]./255; 144 | 145 | PS.Orange1 = [245, 176, 65]./255; 146 | PS.Orange2 = [243, 156, 18]./255; 147 | PS.Orange3 = [214, 137, 16]./255; 148 | PS.Orange4 = [185, 119, 14]./255; 149 | PS.Orange5 = [156, 100, 12]./255; 150 | 151 | PS.DOrange1 = [230, 126, 34]./255; 152 | PS.DOrange2 = [220, 118, 51]./255; 153 | PS.DOrange3 = [211, 84, 0]./255; 154 | PS.DOrange4 = [186, 74, 0]./255; 155 | PS.DOrange5 = [135, 54, 0]./255; 156 | 157 | PS.Grey1 = [244, 246, 247]./255; 158 | PS.Grey2 = [202, 207, 210]./255; 159 | PS.Grey3 = [166, 172, 175]./255; 160 | PS.Grey4 = [144, 148, 151]./255; 161 | PS.Grey5 = [98, 101, 103]./255; 162 | 163 | PS.DGrey1 = [127, 140, 141]./255; 164 | PS.DGrey2 = [112, 123, 124]./255; 165 | PS.DGrey3 = [97, 106, 107]./255; 166 | PS.DGrey4 = [81, 90, 90]./255; 167 | PS.DGrey5 = [66, 73, 73]./255; 168 | 169 | PS.Purple1 = [93, 109, 126]./255; 170 | PS.Purple2 = [52, 73, 94]./255; 171 | PS.Purple3 = [40, 55, 71]./255; 172 | PS.Purple4 = [28, 40, 51]./255; 173 | PS.Purple5 = [23, 32, 42]./255; 174 | 175 | 176 | %======================================================== 177 | % LINE AND MARKER PROPERTIES 178 | 179 | % LineStyles 180 | % '-', '--', ':', '-.' 181 | PS.DefaultLineStyle = '-'; 182 | PS.DefaultLineWidth = 1.5; 183 | 184 | % MarkerStyles 185 | % 'o', '+', '*', 'x', 's'->squares, 'd'->diamonds, 'v'->triangles 186 | PS.DefaultMarkerStyle = 'o'; 187 | 188 | 189 | %======================================================== 190 | % LEGEND PROPERTIES 191 | 192 | PS.DefaultLegendBoxLineWidth = 1.5; 193 | PS.DefaultLegendLocation = 'northeast'; 194 | 195 | 196 | %======================================================== 197 | % AXIS DETAILS 198 | 199 | PS.AxisTickLength = 0.01; 200 | PS.AxisColor = PS.DGrey5; 201 | PS.AxisLabelColor = PS.MyBlack; 202 | 203 | 204 | %======================================================== 205 | % FIGURE SAVING PROPERTIES 206 | 207 | % Big 208 | PS.save_big_TitleFontSize = 28; 209 | PS.save_big_LegendFontSize = 20; 210 | PS.save_big_AxisFontSize = 24; 211 | PS.save_big_PlotTextFontSize = 20; 212 | PS.save_big_AxisNumbersFontSize = 18; 213 | PS.save_big_DefaultLineWidth = 1.5; 214 | PS.save_big_DefaultLegendBoxLineWidth = 1.5; 215 | 216 | 217 | % Small 218 | PS.save_small_TitleFontSize = 15; 219 | PS.save_small_LegendFontSize = 11; 220 | PS.save_small_AxisFontSize = 13; 221 | PS.save_small_PlotTextFontSize = 12; 222 | PS.save_small_AxisNumbersFontSize = 14; 223 | PS.save_small_DefaultLineWidth = 1; 224 | PS.save_small_DefaultLegendBoxLineWidth = .7; 225 | 226 | 227 | % TILED SAVE 228 | 229 | % Big 230 | PS.Tiled.Global.save_big_TitleFontSize = 30; 231 | PS.Tiled.Global.save_big_AxisFontSize = 26; 232 | 233 | PS.Tiled.SubPlot.save_big_TitleFontSize = 26; 234 | PS.Tiled.SubPlot.save_big_LegendFontSize = 18; 235 | PS.Tiled.SubPlot.save_big_AxisFontSize = 22; 236 | PS.Tiled.SubPlot.save_big_PlotTextFontSize = 18; 237 | PS.Tiled.SubPlot.save_big_AxisNumbersFontSize = 16; 238 | 239 | PS.Tiled.SubPlot.save_big_DefaultLineWidth = 1.5; 240 | PS.Tiled.SubPlot.save_big_DefaultLegendBoxLineWidth = 1.5; 241 | 242 | 243 | % Small 244 | PS.Tiled.Global.save_small_TitleFontSize = 20; 245 | PS.Tiled.Global.save_small_AxisFontSize = 12; 246 | 247 | PS.Tiled.SubPlot.save_small_TitleFontSize = 12; 248 | PS.Tiled.SubPlot.save_small_LegendFontSize = 12; 249 | PS.Tiled.SubPlot.save_small_AxisFontSize = 12; 250 | PS.Tiled.SubPlot.save_small_PlotTextFontSize = 12; 251 | PS.Tiled.SubPlot.save_small_AxisNumbersFontSize = 12; 252 | 253 | PS.Tiled.SubPlot.save_small_DefaultLineWidth = 1; 254 | PS.Tiled.SubPlot.save_small_DefaultLegendBoxLineWidth = 1; 255 | 256 | 257 | 258 | % Set Figure Resolution 259 | PS.save_DefaultResolution = 600; 260 | 261 | 262 | end -------------------------------------------------------------------------------- /PlottingTemplates/STANDARDS/SAVE_MY_FIGURE.m: -------------------------------------------------------------------------------- 1 | function saveme = SAVE_MY_FIGURE(fig_comps, fig_filename, save_format) 2 | 3 | %======================================================== 4 | % INCLUDE PLOT_STANDARDS 5 | 6 | PS = PLOT_STANDARDS(); 7 | 8 | 9 | %======================================================== 10 | % GET FIGURE HANDLE 11 | 12 | fig = fig_comps.fig; 13 | 14 | 15 | %======================================================== 16 | % DIFFERENT STYLES FOR NON-TILED VS TILED 17 | 18 | % Non-Tiled Plot 19 | if numel(findobj(fig, 'type', 'tile')) == 0 20 | 21 | %======================================================== 22 | % SET WINDOW SIZE 23 | 24 | % If to save in 'big' mode 25 | if isequal(save_format, 'big') 26 | 27 | %======================================================== 28 | % FOR 'BIG' SAVE IN 'MAXIMIZED' MODE 29 | fig.WindowState = 'maximized'; 30 | 31 | 32 | %======================================================== 33 | % GET CURRENT FIGURE AXES 34 | 35 | % get axes for current figure 36 | ax = fig.CurrentAxes; 37 | 38 | 39 | %======================================================== 40 | % SET PROPERTIES FOR X-AXIS AND Y-AXIS 41 | 42 | % Set Properties for X and Y Axis Numbers 43 | ax.FontName = PS.AxisNumbersFontName; 44 | ax.FontSize = PS.save_big_AxisNumbersFontSize; 45 | ax.FontWeight = 'bold'; 46 | 47 | % Set Properties for X, Y and Z Labels 48 | ax.XLabel.FontName = PS.AxisFont; 49 | ax.YLabel.FontName = PS.AxisFont; 50 | ax.ZLabel.FontName = PS.AxisFont; 51 | 52 | ax.XLabel.FontSize = PS.save_big_AxisFontSize; 53 | ax.YLabel.FontSize = PS.save_big_AxisFontSize; 54 | ax.ZLabel.FontSize = PS.save_big_AxisFontSize; 55 | 56 | ax.XLabel.FontWeight = 'bold'; 57 | ax.YLabel.FontWeight = 'bold'; 58 | ax.ZLabel.FontWeight = 'bold'; 59 | 60 | if length(ax.XLabel.String) > 4 61 | if all(ax.XLabel.String([1, 2, end - 1, end]) == '$$$$') 62 | ax.XLabel.Interpreter = 'latex'; 63 | end 64 | end 65 | if length(ax.YLabel.String) > 4 66 | if all(ax.YLabel.String([1, 2, end - 1, end]) == '$$$$') 67 | ax.YLabel.Interpreter = 'latex'; 68 | end 69 | end 70 | if length(ax.ZLabel.String) > 4 71 | if all(ax.ZLabel.String([1, 2, end - 1, end]) == '$$$$') 72 | ax.ZLabel.Interpreter = 'latex'; 73 | end 74 | end 75 | 76 | 77 | %======================================================== 78 | % SET PROPERTIES FOR TITLE 79 | 80 | ax.Title.FontName = PS.TitleFont; 81 | ax.Title.FontSize = PS.save_big_TitleFontSize; 82 | ax.Title.FontWeight = 'bold'; 83 | if length(ax.Title.String) > 4 84 | if all(ax.Title.String([1, 2, end - 1, end]) == '$$$$') 85 | ax.Title.Interpreter = 'latex'; 86 | end 87 | end 88 | 89 | 90 | %======================================================== 91 | % SET PROPERTIES FOR LEGEND 92 | 93 | if (numel(ax.Legend) ~= 0) 94 | ax.Legend.FontName = PS.LegendFont; 95 | ax.Legend.FontSize = PS.save_big_LegendFontSize; 96 | for i_Legend = 1: length(ax.Legend.String) 97 | if length(ax.Legend.String{i_Legend}) > 4 98 | if all(ax.Legend.String{i_Legend}([1, 2, end - 1, end]) == '$$$$') 99 | ax.Legend.Interpreter = 'latex'; 100 | break 101 | end 102 | end 103 | end 104 | ax.Legend.Box = 'on'; 105 | ax.Legend.LineWidth = PS.save_big_DefaultLegendBoxLineWidth; 106 | ax.Legend.AutoUpdate = 'off'; 107 | if (isfield(fig_comps, 'legendPosition')) 108 | ax.Legend.Position = fig_comps.legendPosition; 109 | end 110 | end 111 | 112 | 113 | %======================================================== 114 | % SET PROPERTIES FOR CHILDREN OF AXES -> LINES, TEXT ON PLOT 115 | 116 | axisChildren = ax.Children; 117 | for i = 1:length(axisChildren) 118 | if isequal(axisChildren(i).Type, 'text') 119 | axisChildren(i).FontName = PS.PlotTextFont; 120 | % axisChildren(i).FontSize = PS.save_big_PlotTextFontSize; 121 | if length(axisChildren(i).String) > 4 122 | if all(axisChildren(i).String([1, 2, end - 1, end]) == '$$$$') 123 | axisChildren(i).Interpreter = 'latex'; 124 | end 125 | end 126 | end 127 | end 128 | 129 | 130 | %======================================================== 131 | % ADJUST AXES PROPERTIES 132 | 133 | ax.Box = 'on'; 134 | ax.TickDir = 'out'; 135 | ax.TickLength = [PS.AxisTickLength, PS.AxisTickLength]; 136 | ax.XMinorTick = 'on'; 137 | ax.YMinorTick = 'on'; 138 | ax.ZMinorTick = 'on'; 139 | ax.XColor = PS.AxisColor; 140 | ax.YColor = PS.AxisColor; 141 | ax.ZColor = PS.AxisColor; 142 | ax.XLabel.Color = PS.AxisLabelColor; 143 | ax.YLabel.Color = PS.AxisLabelColor; 144 | ax.ZLabel.Color = PS.AxisLabelColor; 145 | ax.LineWidth = PS.save_big_DefaultLineWidth; 146 | 147 | 148 | % If to save in 'small' mode 149 | elseif isequal(save_format, 'small') 150 | 151 | %======================================================== 152 | % FOR 'SMALL' SAVE IN 'NORMAL' MODE 153 | 154 | fig.WindowState = 'normal'; 155 | 156 | 157 | %======================================================== 158 | % GET CURRENT FIGURE AXES 159 | 160 | % get axes for current figure 161 | ax = fig.CurrentAxes; 162 | 163 | 164 | %======================================================== 165 | % SET PROPERTIES FOR X-AXIS AND Y-AXIS 166 | 167 | % Set Properties for X and Y Axis Numbers 168 | ax.FontName = PS.AxisNumbersFontName; 169 | ax.FontSize = PS.save_small_AxisNumbersFontSize; 170 | ax.FontWeight = 'bold'; 171 | 172 | % Set Properties for X, Y and Z Labels 173 | ax.XLabel.FontName = PS.AxisFont; 174 | ax.YLabel.FontName = PS.AxisFont; 175 | ax.ZLabel.FontName = PS.AxisFont; 176 | 177 | ax.XLabel.FontSize = PS.save_small_AxisFontSize; 178 | ax.YLabel.FontSize = PS.save_small_AxisFontSize; 179 | ax.ZLabel.FontSize = PS.save_small_AxisFontSize; 180 | 181 | ax.XLabel.FontWeight = 'bold'; 182 | ax.YLabel.FontWeight = 'bold'; 183 | ax.ZLabel.FontWeight = 'bold'; 184 | 185 | if length(ax.XLabel.String) > 4 186 | if all(ax.XLabel.String([1, 2, end - 1, end]) == '$$$$') 187 | ax.XLabel.Interpreter = 'latex'; 188 | end 189 | end 190 | if length(ax.YLabel.String) > 4 191 | if all(ax.YLabel.String([1, 2, end - 1, end]) == '$$$$') 192 | ax.YLabel.Interpreter = 'latex'; 193 | end 194 | end 195 | if length(ax.ZLabel.String) > 4 196 | if all(ax.ZLabel.String([1, 2, end - 1, end]) == '$$$$') 197 | ax.ZLabel.Interpreter = 'latex'; 198 | end 199 | end 200 | 201 | 202 | %======================================================== 203 | % SET PROPERTIES FOR TITLE 204 | 205 | ax.Title.FontName = PS.TitleFont; 206 | ax.Title.FontSize = PS.save_small_TitleFontSize; 207 | ax.Title.FontWeight = 'bold'; 208 | if length(ax.Title.String) > 4 209 | if all(ax.Title.String([1, 2, end - 1, end]) == '$$$$') 210 | ax.Title.Interpreter = 'latex'; 211 | end 212 | end 213 | 214 | 215 | %======================================================== 216 | % SET PROPERTIES FOR LEGEND 217 | 218 | if (numel(ax.Legend) ~= 0) 219 | ax.Legend.FontName = PS.LegendFont; 220 | ax.Legend.FontSize = PS.save_small_LegendFontSize; 221 | for i_Legend = 1: length(ax.Legend.String) 222 | if length(ax.Legend.String{i_Legend}) > 4 223 | if all(ax.Legend.String{i_Legend}([1, 2, end - 1, end]) == '$$$$') 224 | ax.Legend.Interpreter = 'latex'; 225 | break 226 | end 227 | end 228 | end 229 | ax.Legend.Box = 'off'; 230 | ax.Legend.LineWidth = PS.save_small_DefaultLegendBoxLineWidth; 231 | ax.Legend.AutoUpdate = 'off'; 232 | if (isfield(fig_comps, 'legendPosition')) 233 | ax.Legend.Position = fig_comps.legendPosition; 234 | end 235 | end 236 | 237 | 238 | %======================================================== 239 | % SET PROPERTIES FOR CHILDREN OF AXES -> LINES, TEXT ON PLOT 240 | 241 | axisChildren = ax.Children; 242 | for i = 1:length(axisChildren) 243 | if isequal(axisChildren(i).Type, 'text') 244 | axisChildren(i).FontName = PS.PlotTextFont; 245 | axisChildren(i).FontSize = PS.save_small_PlotTextFontSize; 246 | % axisChildren(i).FontSize = PS.save_small_PlotTextFontSize; 247 | if length(axisChildren(i).String) > 4 248 | if all(axisChildren(i).String([1, 2, end - 1, end]) == '$$$$') 249 | axisChildren(i).Interpreter = 'latex'; 250 | end 251 | end 252 | 253 | end 254 | end 255 | 256 | 257 | %======================================================== 258 | % ADJUST AXES PROPERTIES 259 | 260 | ax.Box = 'on'; 261 | ax.TickDir = 'out'; 262 | ax.TickLength = [PS.AxisTickLength, PS.AxisTickLength]; 263 | ax.XMinorTick = 'on'; 264 | ax.YMinorTick = 'on'; 265 | ax.ZMinorTick = 'on'; 266 | ax.XColor = PS.AxisColor; 267 | ax.YColor = PS.AxisColor; 268 | ax.ZColor = PS.AxisColor; 269 | ax.XLabel.Color = PS.AxisLabelColor; 270 | ax.YLabel.Color = PS.AxisLabelColor; 271 | ax.ZLabel.Color = PS.AxisLabelColor; 272 | ax.LineWidth = PS.save_small_DefaultLineWidth; 273 | 274 | end 275 | 276 | % Tiled Plot 277 | elseif numel(findobj(gcf, 'type', 'tile')) == 1 278 | 279 | % If to save in 'big' mode 280 | if isequal(save_format, 'big') 281 | 282 | %======================================================== 283 | % FOR 'SMALL' SAVE IN 'NORMAL' MODE 284 | 285 | fig.WindowState = 'maximized'; 286 | 287 | 288 | %======================================================== 289 | % GET HANDLES FOR THE GLOBAL AND EACH INDIVIDUAL TILE 290 | 291 | % Get handle of the tile object 292 | t1 = fig_comps.t1; 293 | % Get handle to access each individual tile 294 | n = fig_comps.n; 295 | % Get the total number of tiles 296 | num_tiles = numel(n); 297 | 298 | 299 | %======================================================== 300 | % TILE GLOBAL PROPERTIES 301 | 302 | % t1.Padding = 'tight'; 303 | 304 | t1.Title.FontName = PS.TitleFont; 305 | t1.Title.FontSize = PS.Tiled.Global.save_big_TitleFontSize; 306 | t1.Title.FontWeight = 'bold'; 307 | if length(t1.Title.String) > 4 308 | if all(t1.Title.String([1, 2, end - 1, end]) == '$$$$') 309 | t1.Title.Interpreter = 'latex'; 310 | end 311 | end 312 | 313 | t1.XLabel.FontName = PS.AxisFont; 314 | t1.XLabel.FontSize = PS.Tiled.Global.save_big_AxisFontSize; 315 | t1.XLabel.FontWeight = 'bold'; 316 | if length(t1.XLabel.String) > 4 317 | if all(t1.XLabel.String([1, 2, end - 1, end]) == '$$$$') 318 | t1.XLabel.Interpreter = 'latex'; 319 | end 320 | end 321 | 322 | 323 | t1.YLabel.FontName = PS.AxisFont; 324 | t1.YLabel.FontSize = PS.Tiled.Global.save_big_AxisFontSize; 325 | t1.YLabel.FontWeight = 'bold'; 326 | if length(t1.YLabel.String) > 4 327 | if all(t1.YLabel.String([1, 2, end - 1, end]) == '$$$$') 328 | t1.YLabel.Interpreter = 'latex'; 329 | end 330 | end 331 | 332 | 333 | %======================================================== 334 | % TILE PROPERTIES 335 | 336 | for i = 1:num_tiles 337 | n_i = n(i); 338 | 339 | %======================================================== 340 | % SET PROPERTIES FOR X-AXIS AND Y-AXIS 341 | 342 | % Set Properties for X and Y Axis Numbers 343 | n_i.FontName = PS.AxisNumbersFontName; 344 | n_i.FontSize = PS.Tiled.SubPlot.save_big_AxisNumbersFontSize; 345 | n_i.FontWeight = 'bold'; 346 | 347 | % Set Properties for X, Y and Z Labels 348 | n_i.XLabel.FontName = PS.AxisFont; 349 | n_i.YLabel.FontName = PS.AxisFont; 350 | n_i.ZLabel.FontName = PS.AxisFont; 351 | 352 | n_i.XLabel.FontSize = PS.Tiled.SubPlot.AxisFontSize; 353 | n_i.YLabel.FontSize = PS.Tiled.SubPlot.AxisFontSize; 354 | n_i.ZLabel.FontSize = PS.Tiled.SubPlot.AxisFontSize; 355 | 356 | n_i.XLabel.FontWeight = 'bold'; 357 | n_i.YLabel.FontWeight = 'bold'; 358 | n_i.ZLabel.FontWeight = 'bold'; 359 | 360 | if length(n_i.XLabel.String) > 4 361 | if all(n_i.XLabel.String([1, 2, end - 1, end]) == '$$$$') 362 | n_i.XLabel.Interpreter = 'latex'; 363 | end 364 | end 365 | if length(n_i.YLabel.String) > 4 366 | if all(n_i.YLabel.String([1, 2, end - 1, end]) == '$$$$') 367 | n_i.YLabel.Interpreter = 'latex'; 368 | end 369 | end 370 | if length(n_i.ZLabel.String) > 4 371 | if all(n_i.ZLabel.String([1, 2, end - 1, end]) == '$$$$') 372 | n_i.ZLabel.Interpreter = 'latex'; 373 | end 374 | end 375 | 376 | 377 | %======================================================== 378 | % SET PROPERTIES FOR TITLE 379 | 380 | n_i.Title.FontName = PS.TitleFont; 381 | n_i.Title.FontSize = PS.Tiled.SubPlot.save_big_TitleFontSize; 382 | n_i.Title.FontWeight = 'bold'; 383 | if length(n_i.Title.String) > 4 384 | if all(n_i.Title.String([1, 2, end - 1, end]) == '$$$$') 385 | n_i.Title.Interpreter = 'latex'; 386 | end 387 | end 388 | 389 | 390 | %======================================================== 391 | % SET PROPERTIES FOR LEGEND 392 | 393 | if (numel(n_i.Legend) ~= 0) 394 | n_i.Legend.FontName = PS.LegendFont; 395 | n_i.Legend.FontSize = PS.Tiled.SubPlot.save_big_LegendFontSize; 396 | for i_Legend = 1: length(n_i.Legend.String) 397 | if length(n_i.Legend.String{i_Legend}) > 4 398 | if all(n_i.Legend.String{i_Legend}([1, 2, end - 1, end]) == '$$$$') 399 | n_i.Legend.Interpreter = 'latex'; 400 | break 401 | end 402 | end 403 | end 404 | n_i.Legend.Box = 'on'; 405 | n_i.Legend.LineWidth = PS.Tiled.SubPlot.save_big_DefaultLegendBoxLineWidth; 406 | n_i.Legend.AutoUpdate = 'off'; 407 | n_i.Legend.Location = PS.DefaultLegendLocation; 408 | end 409 | 410 | 411 | %======================================================== 412 | % SET PROPERTIES FOR CHILDREN OF AXES -> LINES, TEXT ON PLOT 413 | 414 | axisChildren = n_i.Children; 415 | for j = 1:length(axisChildren) 416 | if isequal(axisChildren(j).Type, 'text') 417 | axisChildren(j).FontName = PS.PlotTextFont; 418 | % axisChildren(j).FontSize = PS.Tiled.SubPlot.save_big_PlotTextFontSize; 419 | if length(axisChildren(j).String) > 4 420 | if all(axisChildren(j).String([1, 2, end - 1, end]) == '$$$$') 421 | axisChildren(j).Interpreter = 'latex'; 422 | end 423 | end 424 | 425 | end 426 | end 427 | 428 | 429 | %======================================================== 430 | % ADJUST AXES PROPERTIES 431 | 432 | n_i.Box = 'on'; 433 | n_i.TickDir = 'out'; 434 | n_i.TickLength = [PS.AxisTickLength, PS.AxisTickLength]; 435 | n_i.XMinorTick = 'on'; 436 | n_i.YMinorTick = 'on'; 437 | n_i.ZMinorTick = 'on'; 438 | n_i.XColor = PS.AxisColor; 439 | n_i.YColor = PS.AxisColor; 440 | n_i.ZColor = PS.AxisColor; 441 | n_i.XLabel.Color = PS.AxisLabelColor; 442 | n_i.YLabel.Color = PS.AxisLabelColor; 443 | n_i.ZLabel.Color = PS.AxisLabelColor; 444 | n_i.LineWidth = PS.Tiled.SubPlot.save_big_DefaultLineWidth; 445 | 446 | end 447 | 448 | % If to save in 'small' mode 449 | elseif isequal(save_format, 'small') 450 | 451 | %======================================================== 452 | % FOR 'SMALL' SAVE IN 'NORMAL' MODE 453 | 454 | fig.WindowState = 'normal'; 455 | 456 | 457 | %======================================================== 458 | % GET HANDLES FOR THE GLOBAL AND EACH INDIVIDUAL TILE 459 | 460 | % Get handle of the tile object 461 | t1 = fig_comps.t1; 462 | % Get handle to access each individual tile 463 | n = fig_comps.n; 464 | % Get the total number of tiles 465 | num_tiles = numel(n); 466 | 467 | 468 | %======================================================== 469 | % TILE GLOBAL PROPERTIES 470 | 471 | % t1.Padding = 'tight'; 472 | 473 | t1.Title.FontName = PS.TitleFont; 474 | t1.Title.FontSize = PS.Tiled.Global.save_small_TitleFontSize; 475 | t1.Title.FontWeight = 'bold'; 476 | if length(t1.Title.String) > 4 477 | if all(t1.Title.String([1, 2, end - 1, end]) == '$$$$') 478 | t1.Title.Interpreter = 'latex'; 479 | end 480 | end 481 | 482 | t1.XLabel.FontName = PS.AxisFont; 483 | t1.XLabel.FontSize = PS.Tiled.Global.save_small_AxisFontSize; 484 | t1.XLabel.FontWeight = 'bold'; 485 | if length(t1.XLabel.String) > 4 486 | if all(t1.XLabel.String([1, 2, end - 1, end]) == '$$$$') 487 | t1.XLabel.Interpreter = 'latex'; 488 | end 489 | end 490 | t1.YLabel.FontName = PS.AxisFont; 491 | t1.YLabel.FontSize = PS.Tiled.Global.save_small_AxisFontSize; 492 | t1.YLabel.FontWeight = 'bold'; 493 | if length(t1.YLabel.String) > 4 494 | if all(t1.YLabel.String([1, 2, end - 1, end]) == '$$$$') 495 | t1.YLabel.Interpreter = 'latex'; 496 | end 497 | end 498 | 499 | 500 | %======================================================== 501 | % TILE PROPERTIES 502 | 503 | for i = 1:num_tiles 504 | n_i = n(i); 505 | 506 | %======================================================== 507 | % SET PROPERTIES FOR X-AXIS AND Y-AXIS 508 | 509 | % Set Properties for X and Y Axis Numbers 510 | n_i.FontName = PS.AxisNumbersFontName; 511 | n_i.FontSize = PS.Tiled.SubPlot.save_small_AxisNumbersFontSize; 512 | n_i.FontWeight = 'bold'; 513 | 514 | % Set Properties for X, Y and Z Labels 515 | n_i.XLabel.FontName = PS.AxisFont; 516 | n_i.YLabel.FontName = PS.AxisFont; 517 | n_i.ZLabel.FontName = PS.AxisFont; 518 | 519 | n_i.XLabel.FontSize = PS.Tiled.SubPlot.save_small_AxisFontSize; 520 | n_i.YLabel.FontSize = PS.Tiled.SubPlot.save_small_AxisFontSize; 521 | n_i.ZLabel.FontSize = PS.Tiled.SubPlot.save_small_AxisFontSize; 522 | 523 | n_i.XLabel.FontWeight = 'bold'; 524 | n_i.YLabel.FontWeight = 'bold'; 525 | n_i.ZLabel.FontWeight = 'bold'; 526 | 527 | if length(n_i.XLabel.String) > 4 528 | if all(n_i.XLabel.String([1, 2, end - 1, end]) == '$$$$') 529 | n_i.XLabel.Interpreter = 'latex'; 530 | end 531 | end 532 | if length(n_i.YLabel.String) > 4 533 | if all(n_i.YLabel.String([1, 2, end - 1, end]) == '$$$$') 534 | n_i.YLabel.Interpreter = 'latex'; 535 | end 536 | end 537 | if length(n_i.ZLabel.String) > 4 538 | if all(n_i.ZLabel.String([1, 2, end - 1, end]) == '$$$$') 539 | n_i.ZLabel.Interpreter = 'latex'; 540 | end 541 | end 542 | 543 | 544 | %======================================================== 545 | % SET PROPERTIES FOR TITLE 546 | 547 | n_i.Title.FontName = PS.TitleFont; 548 | n_i.Title.FontSize = PS.Tiled.SubPlot.save_small_TitleFontSize; 549 | n_i.Title.FontWeight = 'bold'; 550 | if length(n_i.Title.String) > 4 551 | if all(n_i.Title.String([1, 2, end - 1, end]) == '$$$$') 552 | n_i.Title.Interpreter = 'latex'; 553 | end 554 | end 555 | 556 | 557 | %======================================================== 558 | % SET PROPERTIES FOR LEGEND 559 | 560 | if (numel(n_i.Legend) ~= 0) 561 | n_i.Legend.FontName = PS.LegendFont; 562 | n_i.Legend.FontSize = PS.Tiled.SubPlot.save_small_LegendFontSize; 563 | for i_Legend = 1: length(n_i.Legend.String) 564 | if length(n_i.Legend.String{i_Legend}) > 4 565 | if all(n_i.Legend.String{i_Legend}([1, 2, end - 1, end]) == '$$$$') 566 | n_i.Legend.Interpreter = 'latex'; 567 | break 568 | end 569 | end 570 | end 571 | n_i.Legend.Box = 'off'; 572 | n_i.Legend.LineWidth = PS.Tiled.SubPlot.save_small_DefaultLegendBoxLineWidth; 573 | n_i.Legend.AutoUpdate = 'off'; 574 | n_i.Legend.Location = PS.DefaultLegendLocation; 575 | end 576 | 577 | 578 | %======================================================== 579 | % SET PROPERTIES FOR CHILDREN OF AXES -> LINES, TEXT ON PLOT 580 | 581 | axisChildren = n_i.Children; 582 | for j = 1:length(axisChildren) 583 | if isequal(axisChildren(j).Type, 'text') 584 | axisChildren(j).FontName = PS.PlotTextFont; 585 | axisChildren(j).FontSize = PS.Tiled.SubPlot.save_small_PlotTextFontSize; 586 | % axisChildren(j).FontSize = PS.Tiled.SubPlot.save_small_PlotTextFontSize; 587 | if length(axisChildren(j).String) > 4 588 | if all(axisChildren(j).String([1, 2, end - 1, end]) == '$$$$') 589 | axisChildren(j).Interpreter = 'latex'; 590 | end 591 | end 592 | 593 | end 594 | end 595 | 596 | 597 | %======================================================== 598 | % ADJUST AXES PROPERTIES 599 | 600 | n_i.Box = 'on'; 601 | n_i.TickDir = 'out'; 602 | n_i.TickLength = [PS.AxisTickLength, PS.AxisTickLength]; 603 | n_i.XMinorTick = 'on'; 604 | n_i.YMinorTick = 'on'; 605 | n_i.ZMinorTick = 'on'; 606 | n_i.XColor = PS.AxisColor; 607 | n_i.YColor = PS.AxisColor; 608 | n_i.ZColor = PS.AxisColor; 609 | n_i.XLabel.Color = PS.AxisLabelColor; 610 | n_i.YLabel.Color = PS.AxisLabelColor; 611 | n_i.ZLabel.Color = PS.AxisLabelColor; 612 | n_i.LineWidth = PS.Tiled.SubPlot.save_small_DefaultLineWidth; 613 | 614 | end 615 | 616 | end 617 | end 618 | 619 | 620 | 621 | %======================================================== 622 | % SAVE THE FIGURE 623 | 624 | figure_resolution = PS.save_DefaultResolution; 625 | exportgraphics(fig, fig_filename, 'Resolution', figure_resolution); 626 | 627 | 628 | end -------------------------------------------------------------------------------- /PlottingTemplates/STANDARDS/STANDARDIZE_FIGURE.m: -------------------------------------------------------------------------------- 1 | function figure = STANDARDIZE_FIGURE(fig_comps) 2 | 3 | %======================================================== 4 | % INCLUDE PLOT_STANDARDS 5 | 6 | PS = PLOT_STANDARDS(); 7 | 8 | 9 | %======================================================== 10 | % GET FIGURE HANDLE 11 | 12 | fig = fig_comps.fig; 13 | 14 | 15 | %======================================================== 16 | % DIFFERENT STYLES FOR NON-TILED VS TILED 17 | 18 | % Non-Tiled Plot 19 | if numel(findobj(fig, 'type', 'tile')) == 0 20 | 21 | %======================================================== 22 | % PLOT FULLSCREEN BY DEFAULT 23 | 24 | % Make the plot 'maximized'. The plot opens up in fullscreen mode by default 25 | fig.WindowState = 'maximized'; 26 | 27 | 28 | %======================================================== 29 | % GET CURRENT FIGURE AXES 30 | 31 | % get axes for current figure 32 | ax = fig.CurrentAxes; 33 | 34 | 35 | %======================================================== 36 | % SET PROPERTIES FOR X-AXIS AND Y-AXIS 37 | 38 | % Set Properties for X and Y Axis Numbers 39 | ax.FontName = PS.AxisNumbersFontName; 40 | ax.FontSize = PS.AxisNumbersFontSize; 41 | ax.FontWeight = 'bold'; 42 | 43 | % Set Properties for X, Y and Z Labels 44 | ax.XLabel.FontName = PS.AxisFont; 45 | ax.YLabel.FontName = PS.AxisFont; 46 | ax.ZLabel.FontName = PS.AxisFont; 47 | 48 | ax.XLabel.FontSize = PS.AxisFontSize; 49 | ax.YLabel.FontSize = PS.AxisFontSize; 50 | ax.ZLabel.FontSize = PS.AxisFontSize; 51 | 52 | ax.XLabel.FontWeight = 'bold'; 53 | ax.YLabel.FontWeight = 'bold'; 54 | ax.ZLabel.FontWeight = 'bold'; 55 | 56 | if length(ax.XLabel.String) > 4 57 | if all(ax.XLabel.String([1, 2, end - 1, end]) == '$$$$') 58 | ax.XLabel.Interpreter = 'latex'; 59 | end 60 | end 61 | if length(ax.YLabel.String) > 4 62 | if all(ax.YLabel.String([1, 2, end - 1, end]) == '$$$$') 63 | ax.YLabel.Interpreter = 'latex'; 64 | end 65 | end 66 | if length(ax.ZLabel.String) > 4 67 | if all(ax.ZLabel.String([1, 2, end - 1, end]) == '$$$$') 68 | ax.ZLabel.Interpreter = 'latex'; 69 | end 70 | end 71 | 72 | 73 | %======================================================== 74 | % SET PROPERTIES FOR TITLE 75 | 76 | ax.Title.FontName = PS.TitleFont; 77 | ax.Title.FontSize = PS.TitleFontSize; 78 | ax.Title.FontWeight = 'bold'; 79 | if length(ax.Title.String) > 4 80 | if all(ax.Title.String([1, 2, end - 1, end]) == '$$$$') 81 | ax.Title.Interpreter = 'latex'; 82 | end 83 | end 84 | 85 | 86 | %======================================================== 87 | % SET PROPERTIES FOR LEGEND 88 | 89 | if (numel(ax.Legend) ~= 0) 90 | ax.Legend.FontName = PS.LegendFont; 91 | ax.Legend.FontSize = PS.LegendFontSize; 92 | for i_Legend = 1: length(ax.Legend.String) 93 | if length(ax.Legend.String{i_Legend}) > 4 94 | if all(ax.Legend.String{i_Legend}([1, 2, end - 1, end]) == '$$$$') 95 | ax.Legend.Interpreter = 'latex'; 96 | break 97 | end 98 | end 99 | end 100 | ax.Legend.Box = 'on'; 101 | ax.Legend.LineWidth = PS.DefaultLegendBoxLineWidth; 102 | ax.Legend.AutoUpdate = 'off'; 103 | if (isfield(fig_comps, 'legendPosition')) 104 | ax.Legend.Position = fig_comps.legendPosition; 105 | end 106 | end 107 | 108 | 109 | %======================================================== 110 | % SET PROPERTIES FOR CHILDREN OF AXES -> LINES, TEXT ON PLOT 111 | 112 | axisChildren = ax.Children; 113 | for i = 1:length(axisChildren) 114 | if isequal(axisChildren(i).Type, 'text') 115 | axisChildren(i).FontName = PS.PlotTextFont; 116 | axisChildren(i).FontSize = PS.PlotTextFontSize; 117 | if length(axisChildren(i).String) > 4 118 | if all(axisChildren(i).String([1, 2, end - 1, end]) == '$$$$') 119 | axisChildren(i).Interpreter = 'latex'; 120 | end 121 | end 122 | 123 | end 124 | end 125 | 126 | 127 | %======================================================== 128 | % ADJUST AXES PROPERTIES 129 | 130 | ax.Box = 'on'; 131 | ax.TickDir = 'out'; 132 | ax.TickLength = [PS.AxisTickLength, PS.AxisTickLength]; 133 | ax.XMinorTick = 'on'; 134 | ax.YMinorTick = 'on'; 135 | ax.ZMinorTick = 'on'; 136 | ax.XColor = PS.AxisColor; 137 | ax.YColor = PS.AxisColor; 138 | ax.ZColor = PS.AxisColor; 139 | ax.XLabel.Color = PS.AxisLabelColor; 140 | ax.YLabel.Color = PS.AxisLabelColor; 141 | ax.ZLabel.Color = PS.AxisLabelColor; 142 | ax.LineWidth = PS.DefaultLineWidth; 143 | 144 | 145 | % Tiled Plot 146 | elseif numel(findobj(gcf, 'type', 'tile')) == 1 147 | 148 | %======================================================== 149 | % PLOT FULLSCREEN BY DEFAULT 150 | 151 | % Make the plot 'maximized'. The plot opens up in fullscreen mode by default 152 | fig.WindowState = 'maximized'; 153 | 154 | 155 | %======================================================== 156 | % GET HANDLES FOR THE GLOBAL AND EACH INDIVIDUAL TILE 157 | 158 | % Get handle of the tile object 159 | t1 = fig_comps.t1; 160 | % Get handle to access each individual tile 161 | n = fig_comps.n; 162 | % Get the total number of tiles 163 | num_tiles = numel(n); 164 | 165 | 166 | %======================================================== 167 | % TILE GLOBAL PROPERTIES 168 | 169 | t1.Padding = 'loose'; 170 | 171 | t1.Title.FontName = PS.TitleFont; 172 | t1.Title.FontSize = PS.Tiled.Global.TitleFontSize; 173 | t1.Title.FontWeight = 'bold'; 174 | if length(t1.Title.String) > 4 175 | if all(t1.Title.String([1, 2, end - 1, end]) == '$$$$') 176 | t1.Title.Interpreter = 'latex'; 177 | end 178 | end 179 | 180 | t1.XLabel.FontName = PS.AxisFont; 181 | t1.XLabel.FontSize = PS.Tiled.Global.AxisFontSize; 182 | t1.XLabel.FontWeight = 'bold'; 183 | if length(t1.XLabel.String) > 4 184 | if all(t1.XLabel.String([1, 2, end - 1, end]) == '$$$$') 185 | t1.XLabel.Interpreter = 'latex'; 186 | end 187 | end 188 | 189 | t1.YLabel.FontName = PS.AxisFont; 190 | t1.YLabel.FontSize = PS.Tiled.Global.AxisFontSize; 191 | t1.YLabel.FontWeight = 'bold'; 192 | if length(t1.YLabel.String) > 4 193 | if all(t1.YLabel.String([1, 2, end - 1, end]) == '$$$$') 194 | t1.YLabel.Interpreter = 'latex'; 195 | end 196 | end 197 | 198 | 199 | %======================================================== 200 | % TILE PROPERTIES 201 | 202 | for i = 1:num_tiles 203 | n_i = n(i); 204 | 205 | %======================================================== 206 | % SET PROPERTIES FOR X-AXIS AND Y-AXIS 207 | 208 | % Set Properties for X and Y Axis Numbers 209 | n_i.FontName = PS.AxisNumbersFontName; 210 | n_i.FontSize = PS.Tiled.SubPlot.AxisNumbersFontSize; 211 | n_i.FontWeight = 'bold'; 212 | 213 | % Set Properties for X, Y and Z Labels 214 | n_i.XLabel.FontName = PS.AxisFont; 215 | n_i.YLabel.FontName = PS.AxisFont; 216 | n_i.ZLabel.FontName = PS.AxisFont; 217 | 218 | n_i.XLabel.FontSize = PS.Tiled.SubPlot.AxisFontSize; 219 | n_i.YLabel.FontSize = PS.Tiled.SubPlot.AxisFontSize; 220 | n_i.ZLabel.FontSize = PS.Tiled.SubPlot.AxisFontSize; 221 | 222 | n_i.XLabel.FontWeight = 'bold'; 223 | n_i.YLabel.FontWeight = 'bold'; 224 | n_i.ZLabel.FontWeight = 'bold'; 225 | 226 | if length(n_i.XLabel.String) > 4 227 | if all(n_i.XLabel.String([1, 2, end - 1, end]) == '$$$$') 228 | n_i.XLabel.Interpreter = 'latex'; 229 | end 230 | end 231 | if length(n_i.YLabel.String) > 4 232 | if all(n_i.YLabel.String([1, 2, end - 1, end]) == '$$$$') 233 | n_i.YLabel.Interpreter = 'latex'; 234 | end 235 | end 236 | if length(n_i.ZLabel.String) > 4 237 | if all(n_i.ZLabel.String([1, 2, end - 1, end]) == '$$$$') 238 | n_i.ZLabel.Interpreter = 'latex'; 239 | end 240 | end 241 | 242 | 243 | %======================================================== 244 | % SET PROPERTIES FOR TITLE 245 | 246 | n_i.Title.FontName = PS.TitleFont; 247 | n_i.Title.FontSize = PS.Tiled.SubPlot.TitleFontSize; 248 | n_i.Title.FontWeight = 'bold'; 249 | if length(n_i.Title.String) > 4 250 | if all(n_i.Title.String([1, 2, end - 1, end]) == '$$$$') 251 | n_i.Title.Interpreter = 'latex'; 252 | end 253 | end 254 | 255 | 256 | %======================================================== 257 | % SET PROPERTIES FOR LEGEND 258 | 259 | if (numel(n_i.Legend) ~= 0) 260 | n_i.Legend.FontName = PS.LegendFont; 261 | n_i.Legend.FontSize = PS.Tiled.SubPlot.LegendFontSize; 262 | for i_Legend = 1: length(n_i.Legend.String) 263 | if length(n_i.Legend.String{i_Legend}) > 4 264 | if all(n_i.Legend.String{i_Legend}([1, 2, end - 1, end]) == '$$$$') 265 | n_i.Legend.Interpreter = 'latex'; 266 | break 267 | end 268 | end 269 | end 270 | n_i.Legend.Box = 'on'; 271 | n_i.Legend.LineWidth = PS.DefaultLegendBoxLineWidth; 272 | n_i.Legend.AutoUpdate = 'off'; 273 | n_i.Legend.Location = PS.DefaultLegendLocation; 274 | end 275 | 276 | 277 | %======================================================== 278 | % SET PROPERTIES FOR CHILDREN OF AXES -> LINES, TEXT ON PLOT 279 | 280 | axisChildren = n_i.Children; 281 | for j = 1:length(axisChildren) 282 | if isequal(axisChildren(j).Type, 'text') 283 | axisChildren(j).FontName = PS.PlotTextFont; 284 | axisChildren(j).FontSize = PS.Tiled.SubPlot.PlotTextFontSize; 285 | if length(axisChildren(j).String) > 4 286 | if all(axisChildren(j).String([1, 2, end - 1, end]) == '$$$$') 287 | axisChildren(j).Interpreter = 'latex'; 288 | end 289 | end 290 | 291 | end 292 | end 293 | 294 | 295 | %======================================================== 296 | % ADJUST AXES PROPERTIES 297 | 298 | n_i.Box = 'on'; 299 | n_i.TickDir = 'out'; 300 | n_i.TickLength = [PS.AxisTickLength, PS.AxisTickLength]; 301 | n_i.XMinorTick = 'on'; 302 | n_i.YMinorTick = 'on'; 303 | n_i.ZMinorTick = 'on'; 304 | n_i.XColor = PS.AxisColor; 305 | n_i.YColor = PS.AxisColor; 306 | n_i.ZColor = PS.AxisColor; 307 | n_i.XLabel.Color = PS.AxisLabelColor; 308 | n_i.YLabel.Color = PS.AxisLabelColor; 309 | n_i.ZLabel.Color = PS.AxisLabelColor; 310 | n_i.LineWidth = PS.DefaultLineWidth; 311 | 312 | 313 | end 314 | 315 | end 316 | 317 | end 318 | 319 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MATLAB_Defaults 2 | 3 | ## Instructions 4 | A MATLAB repository for setting defaults especially for improving plots 5 | 6 | Start by reading GENERAL_INSTRUCTIONS.txt 7 | 8 | ## Citation 9 | https://doi.org/10.5281/zenodo.7439954 10 | 11 | ## Example Plot: 12 | 13 | ![](PlottingTemplates/Figures/ProfessionalPlots_Image.png) 14 | --------------------------------------------------------------------------------