Repository navigation
Expand file tree
/
Copy pathsetMarkerColor.m
More file actions
54 lines (48 loc) · 1.49 KB
/
Copy pathsetMarkerColor.m
File metadata and controls
54 lines (48 loc) · 1.49 KB
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
function [hMarker] = setMarkerColor(handle,color,alpha)
%setMarkerColor Sets face color & transparency of a marker symbol.
%
% setMarkerColor(handle,color,alpha)
% Set face color and transparency in marker symbol contained
% within a plot handle object.
%
% INPUTS:
% handle : handle of plot or marker
% color : y-coordinates of markers
% alpha : blending of symbol face color (0.0 transparent through
% 1.0 opaque). (Default : 1.0)
%
% OUTPUTS:
% hMarker : handle of marker
%
% CAVEAT:
% Function is fragile with regard to testing for handle type. Desire
% a better means of testing for the handle property.
%
% DEPENDENCY:
% RGBA function that translates a color from multiple formats into a
% [R G B alpha] color-transparency
% RGB triplet function of Ben Mitch:
% https://www.mathworks.com/matlabcentral/fileexchange/1805-rgb-m
% Author: Peter A. Rochford
% Symplectic, LLC
% www.thesymplectic.com
% prochford@thesymplectic.com
% Test for handle
if ~ishandle(handle)
error('Not a handle.')
end
% Get hidden MarkerHandle property (not available in Octave)
drawnow;
% Test for plot handle
test = findobj(handle,'-property','Marker');
if length(test) > 0
% Plot handle
hMarker = handle.MarkerHandle;
else
% Assume marker handle
hMarker = handle;
end
% Set face color and transparency of marker
hMarker.FaceColorData = uint8(255*rgba(color,alpha));
hMarker.FaceColorType = 'truecoloralpha';
end %function setMarkerColor