-
Notifications
You must be signed in to change notification settings - Fork 1
/
cmtplot.m
106 lines (93 loc) · 2.79 KB
/
cmtplot.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
classdef cmtplot < cmtobject
% CMTPLOT collects common CMT plot tasks.
%
% This is probably more convoluted than it needs to be.
% Copyright 2015 the ConfMapTk project developers. See the COPYRIGHT
% file at the top-level directory of this distribution and at
% https://github.com/ehkropf/ConfMapTk.
%
% This file is part of ConfMapTk. It is subject to the license terms in
% the LICENSE file found in the top-level directory of this distribution
% and at https://github.com/ehkropf/ConfMapTk. No part of ConfMapTk,
% including this file, may be copied, modified, propagated, or distributed
% except according to the terms contained in the LICENSE file.
%
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the LICENSE
% file.
properties(Constant)
% colors
black = 'k'
grey = 0.75*[1, 1, 1]
none = 'none'
end
methods
function p = cmtplot
% This is here to allow get/set functionality.
get(p, plotset);
end
end
methods(Static)
function [args, exargs] = closedcurveArgs(varargin)
opts = get(cmtplot);
if nargout > 1
[opts, exargs] = set(opts, varargin{:});
else
opts = set(opts, varargin{:});
end
args = { ...
'color', opts.lineColor, ...
'linewidth', opts.lineWidth ...
};
if ~cmtplot.hasNewGraphics
args(5:6) = {'linesmoothing', opts.lineSmoothing};
end
end
function args = fillargs()
args = {cmtplot.fillcolor, 'edgecolor', cmtplot.filledgecolor};
end
function c = fillcolor()
c = cmtplot.grey;
end
function c = filledgecolor()
c = cmtplot.none;
end
function [args, exargs] = gridArgs(varargin)
opts = get(cmtplot);
if nargout < 2
opts = set(opts, varargin{:});
else
[opts, exargs] = set(opts, varargin{:});
end
args = {
'color', opts.gridColor, ...
'linewidth', opts.lineWidth ...
};
if ~cmtplot.hasNewGraphics
args(5:6) = {'linesmoothing', opts.lineSmoothing};
end
end
function tf = hasNewGraphics()
tf = ~verLessThan('matlab', '8.4');
end
function tf = isFigHandle(val)
if exist('isgraphics', 'builtin') == 5
tf = isgraphics(val, 'figure');
else
% Revert to older way.
if ishghandle(tmp)
tf = strcmp(get(tmp, 'type'), 'figure');
else
tf = false;
end
end
end
function whitefigure(fig)
if ~nargin
fig = gcf;
end
set(fig, 'color', 'white');
end
end
end