0001 function addGradientToAxes( axh )
0002
0003
0004
0005
0006
0007
0008
0009 topCol = [0.87 0.87 0.87];
0010 botCol = [0.98 0.98 0.98];
0011
0012
0013 p = findall( axh, 'Tag', 'FunkyAxes:AxesBackground' );
0014 if ~isempty( p )
0015 delete( p );
0016 end
0017 xlim = get( axh, 'XLim' );
0018 ylim = get( axh, 'YLim' );
0019 if strcmpi( get( axh, 'YDir' ), 'Reverse' )
0020 ylim = fliplr( ylim );
0021 end
0022 zlim = get( axh, 'ZLim' );
0023 clim = get( axh, 'CLim' );
0024
0025 set( axh, 'Layer', 'top' );
0026
0027
0028 r = [ topCol(1)*[1 1] botCol(1)*[1 1] ];
0029 g = [ topCol(2)*[1 1] botCol(2)*[1 1] ];
0030 b = [ topCol(3)*[1 1] botCol(3)*[1 1] ];
0031 cdata = cat( 3, r, g, b );
0032
0033 ptch = patch( ...
0034 'Parent', axh, ...
0035 'XData', [xlim,fliplr(xlim)], ...
0036 'YData', [ylim(1)*[1 1] ylim(2)*[1 1]], ...
0037 'ZData', -inf*ones(1,4), ...
0038 'CData', cdata, ...
0039 'FaceColor', 'interp', ...
0040 'FaceLighting', 'none', ...
0041 'Tag', 'FunkyAxes:AxesBackground', ...
0042 'HandleVisibility', 'off', ...
0043 'HitTest', 'off' );
0044 set( axh, 'CLim', clim );
0045
0046 iSendToBack( axh, ptch )
0047 hold( axh, 'on' );
0048
0049 hgax = handle( axh );
0050 setappdata( axh, 'LimitListeners', {
0051 handle.listener( hgax, findprop( hgax, 'XLim' ), 'PropertyPostSet', @iUpdatePatch )
0052 handle.listener( hgax, findprop( hgax, 'YLim' ), 'PropertyPostSet', @iUpdatePatch )
0053 } );
0054
0055
0056 function iUpdatePatch(~,~)
0057 if ~isempty( ptch ) && ishandle( ptch )
0058 xlim = get( axh, 'XLim' );
0059 ylim = get( axh, 'YLim' );
0060 zlim = get( axh, 'ZLim' );
0061 set( ptch, ...
0062 'XData', [xlim,fliplr(xlim)], ...
0063 'YData', [ylim(1)*[1 1] ylim(2)*[1 1]], ...
0064 'ZData', zlim(1)*ones(1,4) );
0065 end
0066 end
0067
0068 end
0069
0070 function iSendToBack( axh, bg )
0071
0072 children = findall( axh,'Parent',axh );
0073 set( axh, 'Children', [children(children~=bg);bg] )
0074 end