-
Notifications
You must be signed in to change notification settings - Fork 180
/
ContourPlots.m
63 lines (45 loc) · 1.49 KB
/
ContourPlots.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
%% Contour Plots
% How to customize contour plots in MTEX
%%
% Lets consider an arbitrary spherical function which has no practical
% meaning at all but serves as a prototype for pole figures, inverse pole
% figures, Schmidt or Taylor factor maps, etc.
% define the spherical function
sF = 0.01 + 10*S2Fun.smiley
% and plot it as a smooth function
plot(sF,'upper')
mtexColorMap blue2red
mtexColorbar
%%
% Passing the option |contour| to the plot command we may add contours at
% specific levels on top of the smooth plot
% enable on top plotting
hold on
% specify the contour levels
levels = -4:5;
% plot the contours
h = plot(sF,'contour',levels,'linewidth',2,'linecolor','k')
% diable on top plotting
hold off
%%
% The plotting command return a handle |h| to the plotted contours. This
% handle can be used to customize the contour lines. In particular, one can
% use the Matlab command <matlab:doc('clabel') clabel> to add labels to
% specific contour levels.
levels2label = [-2,0:5];
clabel(h.ContourMatrix,h,levels2label,'FontSize',15)
%% A practical example
% The situation becomes a little bit more involved if contour lines should
% be added to multiple plot. Let us consider the pole figures of the
% following ODF
mtexdata dubna
odf = calcODF(pf,'silent')
%%
% Then we may use the option |'ShowText','on'| to display contour labels.
h = pf{4:5}.h;
plotPDF(odf,h)
mtexColorMap LaboTeX
mtexColorbar
hold on
plotPDF(odf,h,'contour',1:2:15,'linecolor','black','linewidth',2,'ShowText','on')
hold off