KerMor  0.9
Model order reduction for nonlinear dynamical systems and nonlinear approximation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PlotManager Class Reference

PlotManager: Small class that allows the same plots generated by some script to be either organized as subplots or single figures. More...

Detailed Description

PlotManager: Small class that allows the same plots generated by some script to be either organized as subplots or single figures.

The key feature of this is that you can call your plotting methods with differently configured PlotManagers, so one time you have it plotting to subplots (=development time) and the next you create single plots with specific export settings (=publication/report time).

This class needs a working export_fig tool that is available at http://www.mathworks.com/matlabcentral/fileexchange/23629

Any openend figure using nextPlot can be exported to a directory using a specified format (any allowed by export_fig).

Examples
%
Run with subplots
PlotManager.demo_Subplots

%

Run with single figures
PlotManager.demo_SinglePlots

%

Saving plots
PlotManager.demo_SavePlots PlotManager.demo_SavePlots_Details

%

Zooms
PlotManager.demo_Zoom
Change in 0.7:
(Daniel Wirtz, 2014-01-15) Changed the property "SingleSize" to "FigureSize". The sizes are now used whenever a new figure is created, independently of being in single or subplot mode.
New in 0.7:
(Daniel Wirtz, 2013-07-05)
  • Compatibility with newest export_fig (June 2013) checked
  • Rewrote the savePlots routine to pass all desired formats to export_fig on the fly
  • New optional parameter "XArgs" that are passed to export_fig as-is
  • New property "WhiteBackground" for white figure background on export (default true)
New in 0.6:
(Daniel Wirtz, 2012-09-25)
  • Now can set Figure names explicitly
  • New property DoubleSaveJPG as sometimes on Linux machines the output is useless on one save iteration (has probably to do with multiple monitors?)
  • MinYTickMarks property, that manually adds more Y tick marks if somehow matlab does not add enough. Output is not really pretty, but when it comes down to it its useful.
New in 0.6:
(Daniel Wirtz, 2012-07-26)
  • Added a new function createZoom to easily copy a Figure (only in 'Single'-mode) and zoom into a specified area.
  • Now the savePlots method optionally takes an argument separate_legends, that specifies for which selected figure to save the legend should be created as extra file (made for too large legends)
New in 0.6:
(Daniel Wirtz, 2012-06-22) Added a new property NoTitlesOnSave, which enables to suppress any axes titles when savePlots is used.
New in 0.6:
(Daniel Wirtz, 2012-06-16) Added a new property UseFileTypeFolders that causes the PlotManager to create subfolders for each file type inside the target directory when using savePlots.
Change in 0.6:
(Daniel Wirtz, 2012-05-07)
  • PlotManager.savePlots now takes a cell array with file extensions, allowing to call the function once and generate all desired output types. Updated info string.
  • New default values (fig + pdf for savePlots, rows=cols=2 for subplots)
  • Only setting axes tight if no manual changes have been made to the axis limits
New in 0.6:
(Daniel Wirtz, 2012-04-27) Added support to optionally pass title, x- and ylabels for upcoming plots. If those values are given they will overwrite any manually set values. This is done by storing the given values and applying them upon nextPlot/done.
New in 0.6:
(Daniel Wirtz, 2012-04-12) Added this class.
Author
Daniel Wirtz
Date
2012-04-12

Copyright (c) 2012, Daniel Wirtz All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted only in compliance with the BSD license, see http://www.opensource.org/licenses/bsd-license.php

Todo:
register onFigureClose callback to remove figure from handles list

Definition at line 17 of file PlotManager.m.

Public Member Functions

 PlotManager (logical single,integer rows,integer cols)
 Creates a new PlotManager. More...
 
function axes ax_handle = nextPlot (char tag,char caption,char xlab,char ylab,cell< char > leg_str,integer numsubplots)
 Creates a new axis to plot in. Depending on the property tools.PlotMananger.Single this will either advance to the next subplot or open up a new figure window of size FigureSize in the center of the main screen. More...
 
function h = copyFigure (nr, newtag)
 Copies the plot with the given number and returns the handle to its axis. More...
 
function h = createZoom (nr, area, tagextra, withlegend)
 
function  done ()
 Finishes the current plotting process. More...
 
function  savePlots (char folder, varargin)
 Saves all plots that have been created thus far to a given folder with given format. More...
 
function  closeAll (selection)
 Closes all currently openend plots and resets the Handles property. More...
 
function  resetCount ()
 Resets the current axes handle count so that subsequent calls to "nextPlot" will result re-returning the current subplot's axes. More...
 
function  delete ()
 
function  setFigureNames (name)
 
function  matchPlotAxes (ax_handles, varargin)
 

Static Public Member Functions

static function pm = demo_SinglePlots ()
 Create a new PlotManager. More...
 
static function pm = demo_Subplots ()
 
static function pm = demo_SavePlots ()
 
static function pm = demo_SavePlots_Details ()
 You can also override some settings or specify what should be saved. More...
 
static function pm = demo_Zoom ()
 

Public Attributes

logical Single = true
 Flag if single plots shall be used for subsequent calls to nextPlot. More...
 
integer MaxFigures = Inf
 Controls the maximum number of simultaneously opened figures. More...
 
rowvec< doubleFigureSize = "[]"
 The figure size for each newly created figure. Set to [] to use system default. More...
 
char FilePrefix = ""
 A prefix that has to be put before each file name for exported plots. More...
 
integer ExportDPI = get("0,'ScreenPixelsPerInch'")
 DPI used for export. See export_fig settings. More...
 
char JPEGQuality = "95"
 JPEG quality used for export. See export_fig settings. More...
 
logical UseFileTypeFolders = true
 Affects the savePlots behaviour. This flag lets the PlotManager create subfolders in the target folder according to the specified file extensions and places any images of that type inside it. More...
 
logical NoTitlesOnSave = false
 Flag that determines if any figures title's are removed when using savePlots. More...
 
 SaveFont = struct("'FontWeight','bold','FontSize',16")
 
logical LeaveOpen = false
 Flag indicating if the plots should be left open once the PlotManager is deleted (as variable) More...
 
cell< charSaveFormats = {"'jpg'"}
 The image formats to use when savePlots is called. More...
 
rowvec< integerAutoTickMarks = true
 An integer number to enforce a minimum number of tickmarks on the respective axes. More...
 
logical DoubleSaveJPG = true
 For some reason on unix machines export_fig sometimes uses the last image saved to as the next one. More...
 
logical WhiteBackground = true
 Flag that determines if a white 'figure' background should be used instead of any set or default (grey) one. More...
 
rowvec< doubleFigures
 Provides access to all figure handles created using nextPlot. More...
 
- Public Attributes inherited from handle
 addlistener
 Creates a listener for the specified event and assigns a callback function to execute when the event occurs. More...
 
 notify
 Broadcast a notice that a specific event is occurring on a specified handle object or array of handle objects. More...
 
 delete
 Handle object destructor method that is called when the object's lifecycle ends. More...
 
 disp
 Handle object disp method which is called by the display method. See the MATLAB disp function. More...
 
 display
 Handle object display method called when MATLAB software interprets an expression returning a handle object that is not terminated by a semicolon. See the MATLAB display function. More...
 
 findobj
 Finds objects matching the specified conditions from the input array of handle objects. More...
 
 findprop
 Returns a meta.property objects associated with the specified property name. More...
 
 fields
 Returns a cell array of string containing the names of public properties. More...
 
 fieldnames
 Returns a cell array of string containing the names of public properties. See the MATLAB fieldnames function. More...
 
 isvalid
 Returns a logical array in which elements are true if the corresponding elements in the input array are valid handles. This method is Sealed so you cannot override it in a handle subclass. More...
 
 eq
 Relational functions example. See details for more information. More...
 
 transpose
 Transposes the elements of the handle object array. More...
 
 permute
 Rearranges the dimensions of the handle object array. See the MATLAB permute function. More...
 
 reshape
 hanges the dimensions of the handle object array to the specified dimensions. See the MATLAB reshape function. More...
 
 sort
 ort the handle objects in any array in ascending or descending order. More...
 

Constructor & Destructor Documentation

PlotManager.PlotManager ( logical  single,
integer  rows,
integer  cols 
)

Creates a new PlotManager.

Parameters
singleIf to create single figures for each call to nextPlot. Default: true
rowsIf on non-single mode, the number of rows to pass to subplot. Default: 2
colsIf on non-single mode, the number of columns to pass to subplot. Default: 2

Definition at line 335 of file PlotManager.m.

References Figures, and Single.

Member Function Documentation

function PlotManager.closeAll (   selection)

Closes all currently openend plots and resets the Handles property.

Definition at line 680 of file PlotManager.m.

References Figures.

Referenced by delete(), and savePlots().

Here is the caller graph for this function:

function h = PlotManager.copyFigure (   nr,
  newtag 
)

Copies the plot with the given number and returns the handle to its axis.

Definition at line 448 of file PlotManager.m.

References Figures, handle.findobj, and isposintscalar().

Referenced by createZoom().

Here is the call graph for this function:

Here is the caller graph for this function:

function h = PlotManager.createZoom (   nr,
  area,
  tagextra,
  withlegend 
)

Definition at line 479 of file PlotManager.m.

References copyFigure(), Figures, handle.findobj, isposintscalar(), and handle.reshape.

Here is the call graph for this function:

function PlotManager.delete ( )

Definition at line 717 of file PlotManager.m.

References closeAll().

Here is the call graph for this function:

static function pm = PlotManager.demo_SavePlots ( )
static

Definition at line 1093 of file PlotManager.m.

function pm = PlotManager.demo_SavePlots_Details ( )
static

You can also override some settings or specify what should be saved.

Generated fields of pm:

Definition at line 1106 of file PlotManager.m.

function pm = PlotManager.demo_SinglePlots ( )
static

Create a new PlotManager.

Generated fields of pm:

Definition at line 1044 of file PlotManager.m.

static function pm = PlotManager.demo_Subplots ( )
static

Definition at line 1078 of file PlotManager.m.

static function pm = PlotManager.demo_Zoom ( )
static

Definition at line 1129 of file PlotManager.m.

function PlotManager.done ( )

Finishes the current plotting process.

Important to call afterwards as the last plot might not get finished off (currently, only "axis tight" is invoked automatically)

Definition at line 515 of file PlotManager.m.

function PlotManager.matchPlotAxes (   ax_handles,
  varargin 
)

Definition at line 734 of file PlotManager.m.

References k.

function axes ax_handle = PlotManager.nextPlot ( char  tag,
char  caption,
char  xlab,
char  ylab,
cell< char leg_str,
integer  numsubplots 
)

Creates a new axis to plot in. Depending on the property tools.PlotMananger.Single this will either advance to the next subplot or open up a new figure window of size FigureSize in the center of the main screen.

If you specify a tag it will be used upon exporting created plots to the file system as filename of the plot.

Parameters
tagThe tag to use for the axes. Default: '
captionThe caption for the axes. Default: []
xlabThe xlabel for the axes. Default: []
ylabThe ylabel for the axes. Default: []
leg_strThe legend entry strings for the axes. Default: {}
numsubplotsThe number of subplots to use up for this next plot. Works only if the number of subplots is contained in the current subplot row (i.e. there are sufficient columns left over to use up the required number of subplots.) Default: 1
Return values
ax_handleThe handle to the new axes object.

Definition at line 365 of file PlotManager.m.

References Figures, FigureSize, and Single.

Referenced by demos.Basics5_KernelsAndApprox(), and demos.SVR.EpsLoss().

Here is the caller graph for this function:

function PlotManager.resetCount ( )

Resets the current axes handle count so that subsequent calls to "nextPlot" will result re-returning the current subplot's axes.

Definition at line 706 of file PlotManager.m.

function PlotManager.savePlots ( char  folder,
  varargin 
)

Saves all plots that have been created thus far to a given folder with given format.

Parameters
folderThe folder to save the current plots to. Default: pwd
vararginDifferent options for saving.
savePlots ( ..., [ "Format", Format_value ] [, "Close", Close_value ]
[, "Selection", Selection_value ] [, "SeparateLegends", SeparateLegends_value ]
[, "XArgs", XArgs_value ] )
Named Parameters for varargin:
  • Format A cell with different formats than given in the PlotManager.SaveFormats property. Default: {jpg}
  • Close Set to true to close all saved figures. ( Default: false )
  • Selection A vector of indices of current figures that should be saved. Default: Save all figures
  • SeparateLegends A vector of indices of current figures that should be saved. Default: All legends stay in-plot
  • XArgs Any extra arguments that should be passed to export_fig. Default: {}

Definition at line 529 of file PlotManager.m.

References all(), closeAll(), Figures, FilePrefix, handle.findobj, SaveFormats, and UseFileTypeFolders.

Here is the call graph for this function:

function PlotManager.setFigureNames (   name)

Definition at line 724 of file PlotManager.m.

References Figures.

Member Data Documentation

PlotManager.AutoTickMarks = true

An integer number to enforce a minimum number of tickmarks on the respective axes.

Set this property to a three element vector containing the numbers of how many tick marks are desired for the X,Y and Z axis.

When a plot is finished (i.e. nextPlot or done is called), it is checked if enough tickmarks are present. If not, the given number of tickmarks is inserted, according to the current -Lim and -Scale property. Set to zero to let MatLab control how many tickmarks are used for the respective axis.

Default: [0 0 0] MinTickMarks = [0 0 0];

Definition at line 236 of file PlotManager.m.

Referenced by models.wh10.WH10Experiment.Experiment1().

PlotManager.DoubleSaveJPG = true

For some reason on unix machines export_fig sometimes uses the last image saved to as the next one.

As a workaround, images to be stored as jpg are saved twice in a row to avoid that.

Default: true

Definition at line 255 of file PlotManager.m.

PlotManager.ExportDPI = get("0,'ScreenPixelsPerInch'")

DPI used for export. See export_fig settings.

Defaults to the current pixels per inch resolution of the screen.

Default: get(0,ScreenPixelsPerInch)

Note
This property has custom functionality when its value is changed.

Definition at line 157 of file PlotManager.m.

PlotManager.Figures

Provides access to all figure handles created using nextPlot.

Note
This property has the MATLAB attribute Transient set to true.
This property has non-standard access specifiers: SetAccess = Private, GetAccess = Public
Matlab documentation of property attributes.

Definition at line 288 of file PlotManager.m.

Referenced by closeAll(), copyFigure(), createZoom(), nextPlot(), PlotManager(), savePlots(), and setFigureNames().

PlotManager.FigureSize = "[]"

The figure size for each newly created figure. Set to [] to use system default.

Is a two dimensional row vector with width and height

Default: []

Definition at line 133 of file PlotManager.m.

Referenced by models.motoneuron.experiments.FrequencyLearning(), and nextPlot().

PlotManager.FilePrefix = ""

A prefix that has to be put before each file name for exported plots.

Default: '

Definition at line 146 of file PlotManager.m.

Referenced by models.mathmod2012.MathMODMain(), and savePlots().

PlotManager.JPEGQuality = "95"

JPEG quality used for export. See export_fig settings.

Default: 95

Definition at line 169 of file PlotManager.m.

PlotManager.MaxFigures = Inf

Controls the maximum number of simultaneously opened figures.

Set to a finite number to make the PlotManager re-use currently openend figures. Has NO effect if Single is set to true.

Default: Inf

Definition at line 120 of file PlotManager.m.

PlotManager.NoTitlesOnSave = false

Flag that determines if any figures title's are removed when using savePlots.

Default: false

Definition at line 199 of file PlotManager.m.

Referenced by models.burgers.Tests.createMoRePaSIIPlots().

PlotManager.SaveFont = struct("'FontWeight','bold','FontSize',16")

Definition at line 210 of file PlotManager.m.

PlotManager.SaveFormats = {"'jpg'"}

The image formats to use when savePlots is called.

Default: {jpg}

Note
This property has custom functionality when its value is changed.

Definition at line 224 of file PlotManager.m.

Referenced by savePlots().

PlotManager.Single = true

Flag if single plots shall be used for subsequent calls to nextPlot.

Default: true

Definition at line 109 of file PlotManager.m.

Referenced by nextPlot(), and PlotManager().

PlotManager.UseFileTypeFolders = true

Affects the savePlots behaviour. This flag lets the PlotManager create subfolders in the target folder according to the specified file extensions and places any images of that type inside it.

This is especially useful for use with LaTeX, as during production simple and fast jpeg-versions of plots can be used and later a single path change includes pdf or eps files.

This setting is only used if more than one file type have been specified.

Default: true

Definition at line 179 of file PlotManager.m.

Referenced by savePlots().

PlotManager.WhiteBackground = true

Flag that determines if a white 'figure' background should be used instead of any set or default (grey) one.

Default: true

Definition at line 268 of file PlotManager.m.


The documentation for this class was generated from the following file: