Skip to content
Jens Engel edited this page Jan 30, 2021 · 1 revision

Description

fig = Figure(name, nRows, nColumns, varargin);

Figure is an abstract (ToDo: really?) class which inherits from the Matlab class handle, such that each plot has an unique instance across the simulation. However, it is not supposed to be directly used to create plots, but as a parent class for subclasses like TimeSeries.

Note: As usual in matlab classes derived from handle, all functions (other than the constructor) have the handle instance as first input argument in their definition. Since this argument is actually not given when called by the user, we omit its reference in the following.

Public Properties

Property Description
figHandle Handle to the Matlab figure
subplotAxisHandles Cell array with handles to the subplots' axes
nRows Number of rows of subplots
nColumns Number of columns of subplots
saveAsTypes File types as which plots shall be saved. Default: {'eps', 'fig', 'png'}
plotLive Boolean, whether to plot live during simulation or not. Default: 1
name Name of figure (string)
finalTime Final time point of simulation, derived from simulation instance, sim.T_sim

Methods

Function Call Description
obj = Figure(name, nRows, nColumns, varargin) Constructor. As optional argument, a cell array defining saveAsTypes can be used.
setFigureOptions(options) Sets figure properties. options has to be a cell array with alternating options names and values, e.g. {'Units', 'centimeters', 'Position', [0 1 30 10]}
setAxisOptions(subplotIndex, options) Sets axis properties. subplotIndex is the index of the subplot as usual in Matlab, i.e. counting from left to right and then from top -> down. options again a cell array with alternating property names and values.
setTitle(myTitle, varargin) Sets title of figure. If a Matlab version >2019 is used, then this is done with sgtitle(). If this function does not exist and there is only one subplot, title of subplot is set. If there are multiple subplots, only the figure name is set.
Optionally, titleOptions can be given (again, cell array with alternating property names and values, e.g. {'FontSize', 12, 'Color', [.3 .4 .5]} ).
setSubplotTitle(subplotIndex, myTitle, varargin) Sets title of subplot with index subplotIndex to myTitle (string).
Optionally, titleOptions can be given (again, cell array with alternating property names and values, e.g. {'FontSize', 12, 'Color', [.3 .4 .5]} ).
setXLabel(subplotIndex, myXLabel, varargin) Sets xLabel of subplot subplotIndex to myXLabel.
Optionally, labelOptions can be given (again, cell array with alternating property names and values, e.g. {'FontSize', 12, 'Color', [.3 .4 .5]} ).
setYLabel(subplotIndex, myYLabel, leftOrRight, varargin) Sets yLabel of subplot subplotIndex to myYLabel. Note that leftOrRight is a string, either 'left' or 'right', and defines for which y-axes the label should be set. If not given, 'left' is set by default
Optionally, labelOptions can be given (again, cell array with alternating property names and values, e.g. {'FontSize', 12, 'Color', [.3 .4 .5]} ).
setZLabel(subplotIndex, myZLabel, varargin) Sets zLabel of subplot subplotIndex to myZLabel.
Optionally, labelOptions can be given (again, cell array with alternating property names and values, e.g. {'FontSize', 12, 'Color', [.3 .4 .5]} ).
show() Sets obj.figHandle.Visible = 'on'. Is called from show()-function of inheriting classes, e.g. TimeSeries.
print(directory) Saves figure in directory (absolute path) as types as is defined in obj.saveAsTypes (see public properties). Is called by simulation instance.