-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7f27318
commit 5d564ae
Showing
9 changed files
with
320 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
% PLOTDEFAULTS Apply a range of default values to the current plot | ||
% | ||
% This class encapsulates common plot operations into one class with | ||
% multiple sizing options which can be customized as desired. PlotDefaults | ||
% always acts on the current plot and current axes. | ||
% | ||
% Methods: | ||
% applyDefaultLabels - apply x,y,z labels with a latex interpreter | ||
% applySizes - apply one of three pre-set size definitions to | ||
% the tick, label and legend. Options are, 'std', | ||
% 'med', 'big'. | ||
% | ||
% Static data: | ||
% colours - set of arrays containing RGB data for different | ||
% colours | ||
% | ||
% Examples: | ||
% PlotDefaults.applyDefaultLabels | ||
% Apply default labels to current plot | ||
% PlotDefaults.applySizes('std') | ||
% Apply the standard set of sizes to the current plot. | ||
% PlotDefaults.colours.blue(:, 1) | ||
% Fetch the 1st shade of blue from the colour palette. | ||
% | ||
% Copyright (C) Matthew Sparkes 2022 - 2023 | ||
|
||
|
||
|
||
|
||
|
||
classdef PlotDefaults < handle | ||
|
||
properties (Constant) | ||
colours = PlotColours.colours; | ||
std = PlotSizes.stdInfo; | ||
med = PlotSizes.medInfo; | ||
big = PlotSizes.bigInfo; | ||
end | ||
|
||
|
||
methods (Static) | ||
applyDefaultLabels; | ||
applySizes(sizes); | ||
end | ||
|
||
methods (Static) | ||
function setLatexDefault | ||
set(groot, 'defaultAxesTickLabelInterpreter','latex'); | ||
set(groot, 'defaultLegendInterpreter','latex'); | ||
end | ||
end | ||
end | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
|
||
|
||
function applyDefaultLabels | ||
|
||
|
||
% Apply default labels to current axes | ||
ax = gca; | ||
|
||
% Set latex as default | ||
PlotDefaults.setLatexDefault; | ||
|
||
% Set all labels | ||
xlabel('$x$', 'Interpreter','latex'); | ||
ylabel('$y$', 'Interpreter','latex'); | ||
zlabel('$z$', 'Interpreter','latex'); | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
|
||
|
||
|
||
function applySizes(sizes) | ||
|
||
% Apply set of standard sizes to current axes | ||
ax = gca; | ||
|
||
|
||
switch sizes | ||
case 'std' | ||
ax.FontSize = PlotDefaults.std.FontSizeTick; | ||
ax.XLabel.FontSize = PlotDefaults.std.FontSizeLab; | ||
ax.YLabel.FontSize = PlotDefaults.std.FontSizeLab; | ||
ax.ZLabel.FontSize = PlotDefaults.std.FontSizeLab; | ||
if ~isempty(ax.Legend) | ||
ax.Legend.FontSize = PlotDefaults.std.FontSizeLeg; | ||
end | ||
case 'med' | ||
ax.FontSize = PlotDefaults.med.FontSizeTick; | ||
ax.XLabel.FontSize = PlotDefaults.med.FontSizeLab; | ||
ax.YLabel.FontSize = PlotDefaults.med.FontSizeLab; | ||
ax.ZLabel.FontSize = PlotDefaults.med.FontSizeLab; | ||
if ~isempty(ax.Legend) | ||
ax.Legend.FontSize = PlotDefaults.med.FontSizeLeg; | ||
end | ||
case 'big' | ||
ax.FontSize = PlotDefaults.big.FontSizeTick; | ||
ax.XLabel.FontSize = PlotDefaults.big.FontSizeLab; | ||
ax.YLabel.FontSize = PlotDefaults.big.FontSizeLab; | ||
ax.ZLabel.FontSize = PlotDefaults.big.FontSizeLab; | ||
if ~isempty(ax.Legend) | ||
ax.Legend.FontSize = PlotDefaults.big.FontSizeLeg; | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
% ----------------------------------------------------------------------- % | ||
% ----------------------------------------------------------------------- % | ||
% COLOURS | ||
% | ||
% A static class which introduces several variables for plot defaults | ||
% | ||
% ----------------------------------------------------------------------- % | ||
% ----------------------------------------------------------------------- % | ||
|
||
|
||
classdef PlotColours < handle | ||
properties (Constant) | ||
colours = PlotColours; | ||
end | ||
|
||
properties | ||
blue | ||
orange | ||
yellow | ||
green | ||
purple | ||
red | ||
end | ||
|
||
methods (Access = private) | ||
function obj = PlotColours | ||
obj.blue = [ | ||
239, 248, 251; | ||
207, 235, 242; | ||
175, 221, 233; | ||
135, 205, 222; | ||
111, 195, 216; | ||
79, 181, 207; | ||
53, 164, 192; | ||
44, 137, 160; | ||
35, 110, 128; | ||
26, 82, 96; | ||
18, 55, 64; | ||
9, 27, 32; | ||
4, 13, 16 | ||
]./255; | ||
|
||
obj.orange = [ | ||
254, 240, 236; | ||
252, 209, 197; | ||
250, 178, 158; | ||
248, 147, 119; | ||
246, 116, 81; | ||
244, 86, 42; | ||
233, 60, 12; | ||
194, 50, 10; | ||
155, 40, 8; | ||
116, 30, 6; | ||
78, 20, 4; | ||
39, 10, 2 | ||
]./255; | ||
|
||
obj.yellow = [ | ||
255, 249, 235; | ||
255, 237, 194; | ||
255, 224, 153; | ||
255, 212, 113; | ||
255, 200, 71; | ||
255, 188, 31; | ||
245, 171, 0; | ||
204, 143, 0; | ||
163, 114, 0; | ||
122, 86, 0; | ||
82, 57, 0; | ||
41, 29, 0 | ||
]./255; | ||
|
||
obj.green = [ | ||
228, 243, 206; | ||
210, 235, 173; | ||
192, 227, 140; | ||
174, 219, 107; | ||
156, 211, 74; | ||
137, 197, 48; | ||
114, 164, 40; | ||
92, 131, 32; | ||
69, 99, 24; | ||
46, 66, 16; | ||
23, 33, 8; | ||
11, 16, 4 | ||
]./255; | ||
|
||
obj.purple = [ | ||
249, 238, 252; | ||
237, 203, 246; | ||
225, 168, 240; | ||
220, 150, 237; | ||
212, 133, 234; | ||
200, 98, 228; | ||
188, 63, 222; | ||
172, 35, 209; | ||
143, 30, 174; | ||
114, 24, 140; | ||
86, 18, 105; | ||
57, 12, 70 | ||
]./255; | ||
|
||
obj.red = [ | ||
249, 220, 220; | ||
243, 185, 185; | ||
237, 150, 150; | ||
234, 133, 133; | ||
231, 115, 115; | ||
225, 81, 81; | ||
220, 46, 46; | ||
192, 33, 33; | ||
157, 27, 27; | ||
122, 21, 21; | ||
87, 15, 15; | ||
52, 9, 9 | ||
]./255; | ||
|
||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
% ----------------------------------------------------------------------- % | ||
% ----------------------------------------------------------------------- % | ||
% PLOT DEFAULTS | ||
% | ||
% Data class | ||
% | ||
% ----------------------------------------------------------------------- % | ||
% ----------------------------------------------------------------------- % | ||
|
||
classdef PlotSizes < handle | ||
properties (Constant) | ||
stdInfo = SizesStd.defs; | ||
medInfo = SizesMed.defs; | ||
bigInfo = SizesBig.defs; | ||
end | ||
end | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
classdef SizesBig < SizesClass | ||
properties (Constant) | ||
defs = SizesBig; | ||
end | ||
|
||
properties | ||
FontSizeTick; | ||
FontSizeLeg; | ||
FontSizeLab; | ||
LineWidth; | ||
end | ||
|
||
methods (Access = private) | ||
function obj = SizesBig | ||
obj.FontSizeTick = 20; | ||
obj.FontSizeLeg = 20; | ||
obj.FontSizeLab = 30; | ||
obj.LineWidth = 1.8; | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
|
||
|
||
|
||
classdef (Abstract) SizesClass < handle | ||
properties (Abstract) | ||
FontSizeTick; | ||
FontSizeLeg; | ||
FontSizeLab; | ||
LineWidth; | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
classdef SizesMed < SizesClass | ||
properties (Constant) | ||
defs = SizesMed; | ||
end | ||
|
||
properties | ||
FontSizeTick; | ||
FontSizeLeg; | ||
FontSizeLab; | ||
LineWidth; | ||
end | ||
|
||
methods (Access = private) | ||
function obj = SizesMed | ||
obj.FontSizeTick = 17; | ||
obj.FontSizeLeg = 17; | ||
obj.FontSizeLab = 22; | ||
obj.LineWidth = 1.65; | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
classdef SizesStd < SizesClass | ||
properties (Constant) | ||
defs = SizesStd; | ||
end | ||
|
||
properties | ||
FontSizeTick; | ||
FontSizeLeg; | ||
FontSizeLab; | ||
LineWidth; | ||
end | ||
|
||
methods (Access = private) | ||
function obj = SizesStd | ||
obj.FontSizeTick = 13; | ||
obj.FontSizeLeg = 15; | ||
obj.FontSizeLab = 16; | ||
obj.LineWidth = 1.5; | ||
end | ||
end | ||
end |