-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMVT_plot_pole_figure.m
More file actions
162 lines (147 loc) · 5.52 KB
/
Copy pathMVT_plot_pole_figure.m
File metadata and controls
162 lines (147 loc) · 5.52 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
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
% MVT_plot_pole_figure - Draw pole figures from Euler angles
%
% Makes use of MTEX to draw pole figures given an array of Euler
% angles, the crystal and sample symmetry and, optionally, a title
% and scale. Can also write output to a file in a supported graphics
% format.
%
% Usage:
% MVT_plot_pole_figure(eulers, CS, SS, ...)
%
% Optional arguments are string - argument pairs. The following
% are supported
%
% MVT_plot_pole_figure(eulers, CS, SS, 'title', title, ...)
% Give the plot a title
%
% MVT_plot_pole_figure(eulers, CS, SS, 'scale', [x y], ...)
% Force colour scale to run from x (minimum) to y (maximim)
%
% MVT_plot_pole_figure(eulers, CS, SS, 'writefile', filename, format, ...)
% Write the image to a file (the file name has the format extension
% added). Format can be 'eps', 'jpg', 'png' or 'tif'.
%
% See also: MS_plot
% Copyright (c) 2012, Andrew Walker
% All rights reserved.
%
% Redistribution and use in source and binary forms,
% with or without modification, are permitted provided
% that the following conditions are met:
%
% * Redistributions of source code must retain the
% above copyright notice, this list of conditions
% and the following disclaimer.
% * Redistributions in binary form must reproduce
% the above copyright notice, this list of conditions
% and the following disclaimer in the documentation
% and/or other materials provided with the distribution.
% * Neither the name of the University of Bristol nor the names
% of its contributors may be used to endorse or promote
% products derived from this software without specific
% prior written permission.
%
% THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS
% AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
% WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
% WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
% PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
% THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
% DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
% CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
% PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
% USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
% CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
% CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
% OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
% SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
function MVT_plot_pole_figure(eulers, CS, SS, varargin)
% Use MTEX to plot a pole figure of a set of Euler
% angles. Euler angles are in Bunge notation and
% degrees. User must pass in cystal symmetry (CS)
% and sample symmetry (SS) generated using MTEX symmetry
% constructor along with a title (a string for the plot
% header) and an array of two values - the mimimum and
% maximum value for the contour scheme.
% Default settings
fix_scale = 0;
scale_setting = [];
add_title = 0;
title_string = '';
write_file = 0;
filename = '';
fileformat = '';
axes = [Miller(1,0,0),Miller(0,1,0),Miller(0,0,1)];
% Process the optional arguments
iarg = 1 ;
while iarg <= (length(varargin))
switch lower(varargin{iarg})
case 'title'
add_title = 1;
title_string = varargin{iarg+1} ;
iarg = iarg + 2 ;
case 'scale'
fix_scale = 1;
scale_setting = varargin{iarg+1} ;
iarg = iarg + 2 ;
case 'writefile'
write_file = 1;
filename = varargin{iarg+1} ;
fileformat = lower(varargin{iarg+2}) ;
iarg = iarg + 3 ;
case 'axes'
axes = varargin{iarg+1};
iarg=iarg+2;
otherwise
error(['Unknown option: ' varargin{iarg}]) ;
end
end
if write_file
switch fileformat
case 'eps'
filename = [filename '.eps'];
fileformat = '-depsc';
case 'jpg'
filename = [filename '.jpg'];
fileformat = '-djpeg';
case 'tif'
filename = [filename '.tif'];
fileformat = '-dtiff';
case 'png'
filename = [filename '.png'];
fileformat = '-dpng';
otherwise
warning('MVT:NoFormat', ...
'File format not recongised - not writing file');
filename = '';
write_file = 0;
end
end
% Work in radians.
eulers_r = eulers*degree;
% Generate a list of orientation objects and an ebsd wrapper
o = orientation('Euler', eulers_r(1,:), eulers_r(2,:), ...
eulers_r(3,:), CS,SS, 'Bunge');
ebsd = EBSD(o);
% Fit an ODF
odf = calcODF(ebsd,'HALFWIDTH', 10*degree, 'silent');
% Make a new figure and plot three pole figures in it...
scrsz = get(0,'ScreenSize');
% Always plot in the same place.
h = figure('Position',[1 scrsz(4)/2 scrsz(3)/2 scrsz(4)/2]);
if fix_scale
plotpdf(odf,axes, ...
'antipodal','silent', 'colorrange', scale_setting);
else
plotpdf(odf,axes, ...
'antipodal','silent');
end
colorbar;
if add_title
set(h, 'Name', title_string);
end
if write_file
set(h, 'PaperPositionMode', 'auto');
print(h, fileformat, filename);
end
end