Mercurial > hg > octave-nkf
annotate scripts/plot/__actual_axis_position__.m @ 9665:1dba57e9d08d
use blas_trans_type for xgemm
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Sat, 26 Sep 2009 10:41:07 +0200 |
parents | ae51d068bbd5 |
children |
rev | line source |
---|---|
8890
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
1 ## Copyright (C) 2009 Ben Abbott |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
2 ## |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
3 ## This file is part of Octave. |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
4 ## |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
5 ## Octave is free software; you can redistribute it and/or modify it |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
6 ## under the terms of the GNU General Public License as published by |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
7 ## the Free Software Foundation; either version 3 of the License, or (at |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
8 ## your option) any later version. |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
9 ## |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
10 ## Octave is distributed in the hope that it will be useful, but |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
11 ## WITHOUT ANY WARRANTY; without even the implied warranty of |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
12 ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
13 ## General Public License for more details. |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
14 ## |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
15 ## You should have received a copy of the GNU General Public License |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
16 ## along with Octave; see the file COPYING. If not, see |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
17 ## <http://www.gnu.org/licenses/>. |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
18 |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
19 ## -*- texinfo -*- |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
20 ## @deftypefn {Function File} {} __actual_axis_position__ (@var{h}) |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
21 ## @deftypefnx {Function File} {} __actual_axis_position__ (@var{axis_struct}) |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
22 ## Undocumented internal function. |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
23 ## @end deftypefn |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
24 |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
25 ## Author: Ben Abbott |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
26 |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
27 function pos = __actual_axis_position__ (axis_obj) |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
28 if (ishandle (axis_obj)) |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
29 axis_obj = get (axis_obj); |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
30 endif |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
31 |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
32 ## When using {rltb}margin, Gnuplot does not handle the specified |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
33 ## aspect ratio properly, so handle it here. |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
34 if (__calc_dimensions__ (axis_obj) == 3) |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
35 ## FIXME -- this works for "axis square", but has not been |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
36 ## thoroughly tested for other aspect ratios. |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
37 aspect_ratio_2d = [max(axis_obj.dataaspectratio(1:2)), ... |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
38 axis_obj.dataaspectratio(3)/sqrt(2)]; |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
39 else |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
40 aspect_ratio_2d = axis_obj.dataaspectratio(1:2); |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
41 endif |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
42 orig_fig_units = get (axis_obj.parent, "units"); |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
43 orig_fig_position = get (axis_obj.parent, "units"); |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
44 unwind_protect |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
45 set (axis_obj.parent, "units", "pixels") |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
46 fig_position = get (axis_obj.parent, "position"); |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
47 pos_in_pixels = axis_obj.position .* fig_position([3, 4, 3, 4]); |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
48 orig_aspect_ratio_2d = pos_in_pixels(3:4); |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
49 rel_aspect_ratio_2d = aspect_ratio_2d ./ orig_aspect_ratio_2d; |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
50 rel_aspect_ratio_2d = rel_aspect_ratio_2d ./ max (rel_aspect_ratio_2d); |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
51 if (rel_aspect_ratio_2d(1) < rel_aspect_ratio_2d(2)); |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
52 dx = (1.0 - rel_aspect_ratio_2d(1)) * pos_in_pixels(3); |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
53 pos_in_pixels = pos_in_pixels + dx*[0.5, 0.0, -1.0, 0.0]; |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
54 elseif (rel_aspect_ratio_2d(1) > rel_aspect_ratio_2d(2)) |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
55 dy = (1.0 - rel_aspect_ratio_2d(2)) * pos_in_pixels(4); |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
56 pos_in_pixels = pos_in_pixels + dy*[0.0, 0.5, 0.0, -1.0]; |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
57 endif |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
58 pos = pos_in_pixels ./ fig_position([3, 4, 3, 4]); |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
59 unwind_protect_cleanup |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
60 set (axis_obj.parent, "units", orig_fig_units) |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
61 set (axis_obj.parent, "units", orig_fig_position) |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
62 end_unwind_protect |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
63 |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
64 endfunction |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
65 |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
66 function nd = __calc_dimensions__ (obj) |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
67 kids = obj.children; |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
68 nd = 2; |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
69 for i = 1:length (kids) |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
70 obj = get (kids(i)); |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
71 switch (obj.type) |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
72 case {"image", "text"} |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
73 ## ignore as they |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
74 case {"line", "patch"} |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
75 if (! isempty (obj.zdata)) |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
76 nd = 3; |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
77 endif |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
78 case "surface" |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
79 nd = 3; |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
80 case "hggroup" |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
81 obj_nd = __calc_dimensions__ (obj); |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
82 if (obj_nd == 3) |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
83 nd = 3; |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
84 endif |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
85 endswitch |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
86 endfor |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
87 endfunction |
ae51d068bbd5
__actual_axis_position__.m: New function to determine position of rendered axes.
Ben Abbott <bpabbott@mac.com>
parents:
diff
changeset
|
88 |