Mercurial > octave-nkf
comparison scripts/plot/util/copyobj.m @ 18528:9c8321ea6f58
copyobj.m: Arrange original and copied plot side-by-side in demos.
* copyobj.m: Arrange original and copied plot side-by-side in demos.
Workaround bug where set (h, 'position', ...) is not respected in FLTK
by multiple calls to drawnow().
author | Rik <rik@octave.org> |
---|---|
date | Thu, 27 Feb 2014 09:56:47 -0800 |
parents | 0187ed948627 |
children | 5ec4b7006b82 |
comparison
equal
deleted
inserted
replaced
18523:c936beeda029 | 18528:9c8321ea6f58 |
---|---|
70 endif | 70 endif |
71 | 71 |
72 endfunction | 72 endfunction |
73 | 73 |
74 | 74 |
75 ## Absurd number of drawnow() function calls in demos is due to problem | |
76 ## with FLTK backend which is not respecting the set ('position') call. | |
77 | |
75 %!demo | 78 %!demo |
76 %! hdl = figure (1234); | 79 %! hobj = figure ('name', 'Original', 'numbertitle', 'off'); |
77 %! clf; | |
78 %! hold on; | 80 %! hold on; |
79 %! x = 1:10; | 81 %! x = 1:10; |
80 %! y = x.^2; | 82 %! y = x.^2; |
81 %! dy = 2 * (.2 * x); | 83 %! dy = 2 * (.2 * x); |
82 %! y2 = (x - 3).^2; | 84 %! y2 = (x - 3).^2; |
83 %! hg = errorbar (x, y, dy,'#~'); | 85 %! hg = errorbar (x, y, dy,'#~'); |
84 %! set (hg, 'marker', '^', 'markerfacecolor', rand (1,3)); | 86 %! set (hg, 'marker', '^', 'markerfacecolor', rand (1,3)); |
85 %! plot (x, y2, 'ok-'); | 87 %! plot (x, y2, 'ok-'); |
86 %! legend ('errorbar', 'line'); | 88 %! legend ('errorbar', 'line'); |
87 %! hnew = copyobj (hdl); | 89 %! drawnow (); |
90 %! pos = get (hobj, 'position'); | |
91 %! scrn = get (0, 'screensize'); | |
92 %! set (hobj, 'position', [scrn(3)/2-pos(3)-10, scrn(4)/2-pos(4)/2, pos(3:4)]); | |
93 %! drawnow (); | |
94 %! hnew = copyobj (hobj); | |
95 %! drawnow (); | |
96 %! set (hnew, 'name', 'Copyobj'); | |
97 %! drawnow (); | |
98 %! set (hnew, 'position', [scrn(3)/2, scrn(4)/2-pos(4)/2, pos(3:4)]); | |
99 %! drawnow (); | |
88 | 100 |
89 %!demo | 101 %!demo |
90 %! hdl = figure (1234); | 102 %! hobj = figure ('name', 'Original', 'numbertitle', 'off'); |
91 %! clf; | |
92 %! subplot (2,2,1); | 103 %! subplot (2,2,1); |
93 %! hold on; | 104 %! hold on; |
94 %! contourf (rand (10, 10)); | 105 %! contourf (rand (10, 10)); |
95 %! colorbar (); | 106 %! colorbar (); |
96 %! subplot (2,2,2); | 107 %! subplot (2,2,2); |
102 %! colorbar ('peer', gca, 'NorthOutside'); | 113 %! colorbar ('peer', gca, 'NorthOutside'); |
103 %! subplot (2,2,4); | 114 %! subplot (2,2,4); |
104 %! imagesc (rand (30, 30)); | 115 %! imagesc (rand (30, 30)); |
105 %! text (15, 15, 'Rotated text', ... | 116 %! text (15, 15, 'Rotated text', ... |
106 %! 'HorizontAlalignment', 'Center', 'Rotation', 30); | 117 %! 'HorizontAlalignment', 'Center', 'Rotation', 30); |
107 %! hnew = copyobj (hdl); | 118 %! drawnow (); |
119 %! pos = get (hobj, 'position'); | |
120 %! scrn = get (0, 'screensize'); | |
121 %! set (hobj, 'position', [scrn(3)/2-pos(3)-10, scrn(4)/2-pos(4)/2, pos(3:4)]); | |
122 %! drawnow (); | |
123 %! hnew = copyobj (hobj); | |
124 %! drawnow (); | |
125 %! set (hnew, 'name', 'Copyobj'); | |
126 %! drawnow (); | |
127 %! set (hnew, 'position', [scrn(3)/2, scrn(4)/2-pos(4)/2, pos(3:4)]); | |
128 %! drawnow (); | |
108 | 129 |
109 %!testif HAVE_MAGICK | 130 %!testif HAVE_MAGICK |
110 %! toolkit = graphics_toolkit (); | 131 %! toolkit = graphics_toolkit (); |
111 %! graphics_toolkit ("gnuplot"); | 132 %! graphics_toolkit ("gnuplot"); |
112 %! unwind_protect | 133 %! unwind_protect |