thesis figure plotting uniformity
This commit is contained in:
1 parent
cfc0ed4748
commit
742b09a459
6 files changed
+126
-3
No files matched your search
@@ -8,8 +8,8 @@ function f = plotParameters(obj, f)
|
|||||||
end
|
end
|
||||||
|
|
||||||
% Distance and tilt sample points
|
% Distance and tilt sample points
|
||||||
d = 0:(obj.alphaDist / 1000):(2*obj.alphaDist);
|
d = 0:(obj.alphaDist / 200):(2*obj.alphaDist);
|
||||||
t = -90:0.1:90;
|
t = -90:0.5:90;
|
||||||
|
|
||||||
% Sample membership functions
|
% Sample membership functions
|
||||||
d_x = obj.distanceMembership(d);
|
d_x = obj.distanceMembership(d);
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Info>
|
||||||
|
<Category UUID="FileClassCategory">
|
||||||
|
<Label UUID="design"/>
|
||||||
|
</Category>
|
||||||
|
</Info>
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<Info location="exportThesisFig.m" type="File"/>
|
||||||
@@ -68,11 +68,18 @@ classdef test_sigmoidSensor < matlab.unittest.TestCase
|
|||||||
s(1) = s(1).initialize(alphaDist(1), betaDist(1), alphaTilt(1), betaTilt(1));
|
s(1) = s(1).initialize(alphaDist(1), betaDist(1), alphaTilt(1), betaTilt(1));
|
||||||
s(2) = s(2).initialize(alphaDist(2), betaDist(2), alphaTilt(2), betaTilt(2));
|
s(2) = s(2).initialize(alphaDist(2), betaDist(2), alphaTilt(2), betaTilt(2));
|
||||||
|
|
||||||
|
set(groot, 'defaultTextInterpreter', 'latex');
|
||||||
|
set(groot, 'defaultAxesTickLabelInterpreter', 'latex');
|
||||||
|
set(groot, 'defaultLegendInterpreter', 'latex');
|
||||||
|
set(groot, 'defaultColorbarTickLabelInterpreter', 'latex');
|
||||||
|
set(groot, 'defaultAxesFontSize', 10); % = \footnotesize in a 12pt doc
|
||||||
|
set(groot, 'defaultTextFontSize', 10);
|
||||||
|
|
||||||
% Plot
|
% Plot
|
||||||
f = s(1).plotParameters;
|
f = s(1).plotParameters;
|
||||||
f = s(2).plotParameters(f);
|
f = s(2).plotParameters(f);
|
||||||
|
|
||||||
legend(["Sensor 1"; "Sensor 2"]);
|
% f = exportThesisFig(f, "sigmoidmodel", 3/4);
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,97 @@
|
|||||||
|
function f = exportThesisFig(f, name, aspect, opts)
|
||||||
|
% Restyle a figure for print and export it as a vector PDF sized for the
|
||||||
|
% thesis, so it can be included at 1:1 (\includegraphics with no width).
|
||||||
|
%
|
||||||
|
% exportThesisFig(f, "sigmoidmodel") % full width, 4:3
|
||||||
|
% exportThesisFig(f, "traj", 1, Width=230) % half-width subfigure
|
||||||
|
% exportThesisFig(f, "traj", 3/4, LineStyles=true) % distinguishable in grayscale
|
||||||
|
%
|
||||||
|
% The figure is modified in place.
|
||||||
|
arguments (Input)
|
||||||
|
f (1, 1) {mustBeA(f, "matlab.ui.Figure")};
|
||||||
|
name (1, 1) string;
|
||||||
|
aspect (1, 1) double {mustBePositive} = 3/4;
|
||||||
|
opts.Width (1, 1) double {mustBePositive} = 469; % points; \the\hsize
|
||||||
|
opts.FontSize (1, 1) double {mustBePositive} = 10; % \footnotesize in a 12pt doc
|
||||||
|
opts.LineWidth (1, 1) double {mustBePositive} = 2; % data lines, points
|
||||||
|
opts.AxesLineWidth (1, 1) double {mustBePositive} = 0.75;
|
||||||
|
opts.MarkerSize (1, 1) double {mustBePositive} = 4;
|
||||||
|
opts.Palette (:, 3) double = okabeIto(); % colorblind- and print-safe
|
||||||
|
opts.Recolor (1, 1) logical = true; % also override explicitly set colors
|
||||||
|
opts.LineStyles (1, 1) logical = false; % cycle line styles per series
|
||||||
|
opts.Raster (1, 1) logical = false; % for very dense plots
|
||||||
|
opts.OutDir (1, 1) string = matlab.project.rootProject().RootFolder;
|
||||||
|
end
|
||||||
|
arguments (Output)
|
||||||
|
f (1, 1) {mustBeA(f, "matlab.ui.Figure")};
|
||||||
|
end
|
||||||
|
|
||||||
|
styles = ["-", "--", ":", "-."];
|
||||||
|
nColors = size(opts.Palette, 1);
|
||||||
|
|
||||||
|
% Text
|
||||||
|
set(findall(f, '-property', 'Interpreter'), 'Interpreter', 'latex');
|
||||||
|
set(findall(f, '-property', 'TickLabelInterpreter'), 'TickLabelInterpreter', 'latex');
|
||||||
|
set(findall(f, '-property', 'FontSize'), 'FontSize', opts.FontSize);
|
||||||
|
|
||||||
|
% Axes: frame width, and palette for any series that pick their color automatically
|
||||||
|
for ax = findall(f, 'Type', 'axes')'
|
||||||
|
ax.LineWidth = opts.AxesLineWidth;
|
||||||
|
ax.ColorOrder = opts.Palette;
|
||||||
|
if opts.LineStyles
|
||||||
|
ax.LineStyleOrder = styles;
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
% Data series. SeriesIndex is the series' position in its axes' color
|
||||||
|
% order, so it keeps the palette assignment consistent with the legend.
|
||||||
|
series = findall(f, '-property', 'SeriesIndex');
|
||||||
|
for s = series'
|
||||||
|
k = s.SeriesIndex;
|
||||||
|
if ~isnumeric(k) || k < 1
|
||||||
|
continue; % series excluded from the color order
|
||||||
|
end
|
||||||
|
c = opts.Palette(mod(k - 1, nColors) + 1, :);
|
||||||
|
% Line-type series have a single Color; bars/areas have Face/EdgeColor
|
||||||
|
% instead, and keep their thin default outline
|
||||||
|
isLine = isprop(s, 'Color');
|
||||||
|
isScatter = isa(s, 'matlab.graphics.chart.primitive.Scatter');
|
||||||
|
|
||||||
|
if isLine || isScatter
|
||||||
|
s.LineWidth = opts.LineWidth;
|
||||||
|
end
|
||||||
|
if isprop(s, 'MarkerSize')
|
||||||
|
s.MarkerSize = opts.MarkerSize;
|
||||||
|
end
|
||||||
|
if opts.LineStyles && isLine && ~strcmp(s.LineStyle, 'none')
|
||||||
|
s.LineStyle = styles(mod(k - 1, numel(styles)) + 1);
|
||||||
|
end
|
||||||
|
if opts.Recolor
|
||||||
|
if isLine
|
||||||
|
s.Color = c; % line, stair, errorbar, function plots
|
||||||
|
end
|
||||||
|
if isprop(s, 'FaceColor') && ~ischar(s.FaceColor)
|
||||||
|
s.FaceColor = c; % bar, area, histogram (leaves 'none'/'flat' alone)
|
||||||
|
end
|
||||||
|
if isScatter && size(s.CData, 1) <= 1
|
||||||
|
s.CData = c; % single-color scatter (leaves colormapped ones alone)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
% Page size in points so the PDF is exactly Width wide, independent of
|
||||||
|
% the on-screen window (which the window manager may resize)
|
||||||
|
w = opts.Width;
|
||||||
|
h = aspect * w;
|
||||||
|
f.PaperUnits = 'points';
|
||||||
|
f.PaperPositionMode = 'manual';
|
||||||
|
f.PaperPosition = [0, 0, w, h];
|
||||||
|
f.PaperSize = [w, h];
|
||||||
|
|
||||||
|
if opts.Raster
|
||||||
|
renderer = {'-image', '-r300'};
|
||||||
|
else
|
||||||
|
renderer = {'-vector'};
|
||||||
|
end
|
||||||
|
print(f, fullfile(opts.OutDir, name + ".pdf"), '-dpdf', renderer{:});
|
||||||
|
end
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
function p = okabeIto()
|
||||||
|
% Okabe & Ito (2008) colorblind-safe palette, minus yellow (too light on
|
||||||
|
% white paper). Returns an N-by-3 RGB matrix, e.g. colororder(okabeIto()).
|
||||||
|
p = [ 0, 114, 178; % blue
|
||||||
|
213, 94, 0; % vermillion
|
||||||
|
0, 158, 115; % bluish green
|
||||||
|
204, 121, 167; % reddish purple
|
||||||
|
86, 180, 233; % sky blue
|
||||||
|
230, 159, 0; % orange
|
||||||
|
0, 0, 0] / 255;
|
||||||
|
end
|
||||||
Reference in new issue
Block a user