*** Wartungsfenster jeden ersten Mittwoch vormittag im Monat ***

Skip to content
Snippets Groups Projects
Commit 61d8ae23 authored by Innerberger, Michael's avatar Innerberger, Michael
Browse files

Introduce DataCategory that encapsulates plotting behavior

parent b7aca589
No related merge requests found
...@@ -43,15 +43,5 @@ function ax = plot(obj, xVariable, yVariable) ...@@ -43,15 +43,5 @@ function ax = plot(obj, xVariable, yVariable)
yVariable = setdiff(yVariable, obj.timeVariable); yVariable = setdiff(yVariable, obj.timeVariable);
% Creates double logarithmic splot % Creates double logarithmic splot
ax = obj.plotLevel(@loglog, xVariable, yVariable); ax = obj.plotLevel(DataCategory.ERROR, xVariable, yVariable);
% Add title
title(ax, 'Convergence history plot');
% Add axes labels
xlabel(ax, xVariable);
ylabel(ax, 'error');
% Update legend
configureLegend(ax, 'northeast');
end end
\ No newline at end of file
...@@ -40,15 +40,5 @@ function ax = plotAbsolute(obj, xVariable, yVariable) ...@@ -40,15 +40,5 @@ function ax = plotAbsolute(obj, xVariable, yVariable)
yVariable = intersect(yVariable, obj.absoluteVariable); yVariable = intersect(yVariable, obj.absoluteVariable);
% Creates semilogx plot % Creates semilogx plot
ax = obj.plotLevel(@semilogx, xVariable, yVariable); ax = obj.plotLevel(DataCategory.ABSOLUTE, xVariable, yVariable);
% Add title
title(ax, 'Value plot');
% Add axes labels
xlabel(ax, xVariable);
ylabel(ax, 'value');
% Update legend
configureLegend(ax, 'northeast');
end end
\ No newline at end of file
function ax = plotLevel(obj, plotFunction, xVariable, yVariable) function ax = plotLevel(obj, category, xVariable, yVariable)
%%PLOTLEVEL auxiliary private function for creation of plots for usage in %%PLOTLEVEL auxiliary private function for creation of plots for usage in
%LevelData/plot, LevelData/plotTime, and LevelData/plotAbsolute, calls the %LevelData/plot, LevelData/plotTime, and LevelData/plotAbsolute, uses the
%specified plotFunction for the plot of variables in yVariable with %specified DataCategory for the plot of variables in yVariable with
%respect to xVariable, returns handle to axis object %respect to xVariable, returns handle to axis object
% ax = PLOTLEVEL(obj, plotFunction, xVariable, yVariable, ...) % ax = PLOTLEVEL(obj, category, xVariable, yVariable, ...)
% Copyright 2023 Philipp Bringmann % Copyright 2023 Philipp Bringmann
% %
...@@ -23,7 +23,7 @@ function ax = plotLevel(obj, plotFunction, xVariable, yVariable) ...@@ -23,7 +23,7 @@ function ax = plotLevel(obj, plotFunction, xVariable, yVariable)
arguments arguments
obj obj
plotFunction function_handle category DataCategory
xVariable {mustBeTextScalar} xVariable {mustBeTextScalar}
yVariable cell yVariable cell
end end
...@@ -39,7 +39,7 @@ function ax = plotLevel(obj, plotFunction, xVariable, yVariable) ...@@ -39,7 +39,7 @@ function ax = plotLevel(obj, plotFunction, xVariable, yVariable)
% Iterate over given variables % Iterate over given variables
for j = 1:length(yVariable) for j = 1:length(yVariable)
if obj.type.(yVariable{j}).rawType ~= RawType.FLOAT if obj.type(yVariable{j}).rawType ~= RawType.FLOAT
continue continue
end end
...@@ -52,7 +52,7 @@ function ax = plotLevel(obj, plotFunction, xVariable, yVariable) ...@@ -52,7 +52,7 @@ function ax = plotLevel(obj, plotFunction, xVariable, yVariable)
variableLabel = yVariable{j}; variableLabel = yVariable{j};
end end
% Create plot % Create plot
plotFunction( ... category.plotFunction( ...
ax, xValue, yValue, '-', ... ax, xValue, yValue, '-', ...
'Marker', MARKER{mod(j, length(MARKER))}, ... 'Marker', MARKER{mod(j, length(MARKER))}, ...
'Color', COLOURORDER(j, :), ... 'Color', COLOURORDER(j, :), ...
...@@ -61,4 +61,10 @@ function ax = plotLevel(obj, plotFunction, xVariable, yVariable) ...@@ -61,4 +61,10 @@ function ax = plotLevel(obj, plotFunction, xVariable, yVariable)
% Add new line into the current figure when calling plotConvergence again % Add new line into the current figure when calling plotConvergence again
hold(ax, 'on'); hold(ax, 'on');
end end
% Set plot appearance
title(ax, category.title);
xlabel(ax, xVariable);
ylabel(ax, category.yLabel);
configureLegend(ax, category.legendLocation);
end end
...@@ -39,15 +39,5 @@ function ax = plotTime(obj, xVariable, yVariable) ...@@ -39,15 +39,5 @@ function ax = plotTime(obj, xVariable, yVariable)
yVariable = intersect(yVariable, obj.timeVariable); yVariable = intersect(yVariable, obj.timeVariable);
% Creates double logarithmic splot % Creates double logarithmic splot
ax = obj.plotLevel(@loglog, xVariable, yVariable); ax = obj.plotLevel(DataCategory.TIME, xVariable, yVariable);
% Add title
title(ax, 'Time plot');
% Add axes labels
xlabel(ax, xVariable);
ylabel(ax, 'runtime');
% Update legend
configureLegend(ax, 'northwest');
end end
\ No newline at end of file
classdef DataCategory
enumeration
ERROR(@loglog, 'Convergence history plot', 'error', 'northeast')
ABSOLUTE(@semilogx, 'Value plot', 'value', 'northeast')
TIME(@loglog, 'Time plot', 'runtime', 'northwest')
end
properties (SetAccess=immutable)
plotFunction function_handle
title string
yLabel string
legendLocation string
end
methods
function obj = DataCategory(plotFunction, title, yLabel, legendLocation)
obj.plotFunction = plotFunction;
obj.title = title;
obj.yLabel = yLabel;
obj.legendLocation = legendLocation;
end
end
end
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment