-
Notifications
You must be signed in to change notification settings - Fork 8
/
magnifyOnFigure_examples.m
213 lines (187 loc) · 6.61 KB
/
magnifyOnFigure_examples.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
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% NAME: magnifyOnFigure_examples
%
% AUTHOR: David Fernandez Prim ([email protected])
% REVISION: Hildo Guillardi Júnior
%
% PURPOSE: Shows the funcionality of 'magnifyOnFigure'
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clc
clear all
close all
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Default interactive mode
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
close all
disp( sprintf('This is the default interactive operation mode of ''magnifyOnFigure''') )
fig = figure;
hold on
plot(rand(100,1), 'b'); plot(rand(300, 1), 'r');
grid on
hold off
magnifyOnFigure;
disp('Press a key...')
pause
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Figure handle passed as an input argument
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
close all
disp( sprintf('The figure handle is here passed as an input argument.') )
fig = figure;
hold on
plot(rand(100,1), 'b'); plot(rand(300, 1), 'r');
grid on
hold off
magnifyOnFigure(fig);
disp('Press a key...')
pause
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Properties (in interactive mode)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
close all
disp( sprintf('Playing arround with the properties in interactive mode...') )
figHandler = figure;
hold on
plot(rand(100,1), 'b'); plot(rand(300, 1), 'r');
grid on
hold off
ylim([0 2]);
magnifyOnFigure(...
figHandler,...
'units', 'pixels',...
'magnifierShape', 'ellipse',...
'initialPositionSecondaryAxes', [326.933 259.189 164.941 102.65],...
'initialPositionMagnifier', [174.769 49.368 14.1164 174.627],...
'mode', 'interactive',...
'displayLinkStyle', 'straight',...
'edgeWidth', 2,...
'edgeColor', 'black',...
'secondaryAxesFaceColor', [0.91 0.91 0.91]...
);
disp('Press a key...')
pause
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Properties (in manual mode)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
close all
disp( sprintf('Or in manual mode.') )
figHandler = figure;
hold on
plot(rand(100,1), 'b'); plot(rand(300, 1), 'r');
grid on
hold off
ylim([0 2]);
magnifyOnFigure(...
figHandler,...
'units', 'pixels',...
'initialPositionSecondaryAxes', [326.933 259.189 164.941 102.65],...
'initialPositionMagnifier', [174.769 49.368 14.1164 174.627],...
'mode', 'manual',...
'displayLinkStyle', 'straight',...
'edgeWidth', 2,...
'edgeColor', 'black',...
'secondaryAxesFaceColor', [0.91 0.91 0.91]...
);
disp('Press a key...')
pause
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Working on images also
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
close all
disp( sprintf('How the tool works on images.') )
h = figure;
load clown;
image(X);
colormap(map) ;
axis image
magnifyOnFigure(h, 'displayLinkStyle', 'straight',...
'EdgeColor', 'white',...
'magnifierShape', 'rectangle',...
'frozenZoomAspectratio', 'on',...
'edgeWidth', 2);
disp('Press a key...')
pause
close all
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Working on contour plots
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
close all
disp( sprintf('How the tool works on contour plots.') )
scrsz = get(0, 'ScreenSize');
h = figure('Position', [0.01*scrsz(3), 0.25*scrsz(4), 0.65*scrsz(3), 0.60*scrsz(4)]);
load clown;
hc1 = contour(X, 'LineWidth', 2);
axis image
magnifyOnFigure;
disp('Press a key...')
pause
close all
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Properties (in interactive mode)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
close all
disp( sprintf('Using multiple magnifiers on the same axis...') )
figHandler = figure;
hold on
plot(rand(100,1), 'b'); plot(rand(300, 1), 'r');
grid on
hold off
ylim([0 2]);
magnifyOnFigure(...
figHandler,...
'units', 'pixels',...
'magnifierShape', 'rectangle',...
'initialPositionSecondaryAxes', [105.6 278.81 130.2 102.69],...
'initialPositionMagnifier', [106.56 47.2 18.6823 186.519],...
'mode', 'interactive',...
'displayLinkStyle', 'straight',...
'edgeWidth', 2,...
'edgeColor', 'black',...
'secondaryAxesFaceColor', [0.91 0.91 0.91]...
);
magnifyOnFigure(...
figHandler,...
'units', 'pixels',...
'magnifierShape', 'rectangle',...
'initialPositionSecondaryAxes', [365.6 275.81 130.2 102.69],...
'initialPositionMagnifier', [211.459 47.2 18.6823 186.519],...
'mode', 'interactive',...
'displayLinkStyle', 'straight',...
'edgeWidth', 2,...
'edgeColor', 'black',...
'secondaryAxesFaceColor', [0.91 0.91 0.91]...
);
magnifyOnFigure(...
figHandler,...
'units', 'pixels',...
'magnifierShape', 'rectangle',...
'initialPositionSecondaryAxes', [364.6 78.81 130.2 102.69],...
'initialPositionMagnifier', [270.827 47.2 18.6823 186.519],...
'mode', 'interactive',...
'displayLinkStyle', 'straight',...
'edgeWidth', 2,...
'edgeColor', 'black',...
'secondaryAxesFaceColor', [0.91 0.91 0.91]...
);
%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Log graph
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
close all
disp( sprintf('''magnifyOnFigure'' in a logarithm X graph plot') )
fig = figure;
plot(rand(100,1), 'b')
grid on
set(gca, 'XScale', 'log')
magnifyOnFigure;
disp('Press a key...')
pause
close all
disp( sprintf('''magnifyOnFigure'' in a logarithm Y graph plot') )
fig = figure;
plot(rand(100,1), 'b')
grid on
set(gca, 'YScale', 'log')
magnifyOnFigure;
disp('Press a key...')
pause