Take a look at the function __calc_dimensions__ in __go_draw_axes__.m. I've cut-n-pasted it below. The input "obj" is the property structure for an axis.
function nd = __calc_dimensions__ (obj)
kids = obj.children;
nd = 2;
for i = 1:length (kids)
obj = get (kids(i));
switch (obj.type)
case {"image", "text"}
## ignore as they
case {"line", "patch"}
if (! isempty (obj.zdata))
nd = 3;
endif
case "surface"
nd = 3;
case "hggroup"
obj_nd = __calc_dimensions__ (obj);
if (obj_nd == 3)
nd = 3;
endif
endswitch
endfor
endfunction