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
|
%%NAME
%% eimagesc - draw scaled image of a matrix
%%
%%SYNOPSIS
%% x=eimagesc(matrix[,colorMap[,legendOrientation[,legendScale]]])
%%
%%PARAMETER(S)
%% x transformed output matrix with values of color numbers
%% matrix matrix for image
%% colorMap define own colormap
%% legendOrientation side of the image where the legend appears
%% character 's'(south),'n'(north),'w'(west) or 'e'(east)
%% (default orientation is south)
%% legendScale scale vector of legend [start step end]
%% special cases of scale vector are:
%% if start=0 and end=0 then autorange=on
%% if step=0 then autoscale=on
%% (default scale vector=[0 0 0])
%%
%%GLOBAL PARAMETER(S)
%% ePlotAreaPos
%% ePlotAreaWidth
%% ePlotAreaHeight
%% eImageDefaultColorMap
%% eYAxisWestScale
%% eXAxisSouthScale
%% eImageLegendScale
%% eImageLegendVisible
%% eImageLegendPos
%% eImageLegendHeight
%% eImageLegendWidth
%% eImageLegendLabelDistance
%% eImageLegendValueFormat
%% eImageLegendLabelText
%% eAxesTicLongLength
%% eAxesTicShortLength
%% eAxesTicLongMaxN
%% eAxesValueSpace
%% eAxesValueFontSize
%% eAxesLabelFontSize
%% eAxesLabelTextFont
%% eAxesLineWidth
% written by Stefan Mueller stefan.mueller@fgan.de
function x=eimagesc(matrix,colorMap,legendOrientation,legendScale)
if (nargin>4)
usage('x=eimagesc (matrix [ ,colorMap[,legendOrientation[,legendScale]]])');
end
eglobpar;
if nargin==0
currentDir=pwd;
eval(['cd ',ePath]);
eval(['load default.img']);
eval(['cd ',currentDir]);
matrix=default;
ePlotTitleText='Anna and Leah';
end
if nargin<4
legendScale=eImageLegendScale;
end
if nargin<3
legendOrientation='s';
end
if nargin<2
colorMap=ecolors(eImageDefaultColorMap);
end
% scale image
if legendScale(1)==legendScale(3)
minval=min (min (matrix));
maxval=max (max (matrix));
else
minval=legendScale(1);
maxval=legendScale(3);
end
legendScale(1)=minval;
legendScale(3)=maxval;
if (maxval - minval)<=1000*eps
maxval=minval+1000*eps;
end
x = fix ((matrix - minval) / (maxval - minval) *...
(length (colorMap) - 1)) + 1;
eimage(x,colorMap)
% image axes
if eYAxisWestScale(1)==eYAxisWestScale(3)
eYAxisWestScale=[size(matrix,1) 0 0];
end
if eXAxisSouthScale(1)==eXAxisSouthScale(3)
eXAxisSouthScale=[0 0 size(matrix,2)];
end
egrid;
eaxes;
% color legend
if eImageLegendVisible
if eImageLegendWidth==0
if legendOrientation=='s' | ...
legendOrientation=='n'
xl=ePlotAreaWidth;
yl=eImageLegendHeight;
scaleLength=xl;
else
yl=ePlotAreaHeight;
xl=eImageLegendHeight;
scaleLength=yl;
end
else
if legendOrientation=='s' | ...
legendOrientation=='n'
xl=eImageLegendWidth;
yl=eImageLegendHeight;
scaleLength=xl;
else
xl=eImageLegendHeight;
yl=eImageLegendWidth;
scaleLength=yl;
end
end
scaleSpace=eAxesTicLongLength+eAxesValueSpace+eAxesValueFontSize;
if legendOrientation=='s'
colorImage=(1:length(colorMap));
legendPosX=ePlotAreaPos(1)+eImageLegendPos(1);
legendPosY=ePlotAreaPos(2)+eImageLegendPos(2);
scalePosX=legendPosX;
scalePosY=legendPosY;
textPosX=scalePosX+scaleLength/2;
textPosY=scalePosY-scaleSpace-eAxesLabelFontSize*0.72-...
eImageLegendLabelDistance;
textAngle=0;
elseif legendOrientation=='n'
colorImage=(1:length(colorMap));
legendPosX=(ePlotAreaPos(1)+eImageLegendPos(1));
legendPosY=(ePlotAreaPos(2)+ePlotAreaHeight-eImageLegendPos(2));
scalePosX=legendPosX;
scalePosY=legendPosY+yl;
textPosX=scalePosX+scaleLength/2;
textPosY=scalePosY+scaleSpace+yl+eAxesLabelFontSize*0.72+...
eImageLegendLabelDistance;
textAngle=0;
elseif legendOrientation=='e'
colorImage=(length(colorMap):-1:1)';
legendPosX=(ePlotAreaPos(1)+ePlotAreaWidth-eImageLegendPos(2));
legendPosY=(ePlotAreaPos(2)+eImageLegendPos(1));
scalePosX=legendPosX+xl;
scalePosY=legendPosY;
textPosX=scalePosX+scaleSpace+xl+eAxesLabelFontSize*0.72+...
eImageLegendLabelDistance;
textPosY=scalePosY+scaleLength/2;
textAngle=90;
elseif legendOrientation=='w'
colorImage=(length(colorMap):-1:1)';
legendPosX=(ePlotAreaPos(1)+eImageLegendPos(2)-xl);
legendPosY=(ePlotAreaPos(2)-eImageLegendPos(1));
scalePosX=legendPosX;
scalePosY=legendPosY;
textPosX=scalePosX-scaleSpace-eAxesLabelFontSize*0.72-...
eImageLegendLabelDistance;
textPosY=scalePosY+scaleLength/2;
textAngle=90;
end
eimagexy(eFile,colorImage,colorMap,...
legendPosX*eFac,legendPosY*eFac,xl*eFac,yl*eFac);
erect(eFile,legendPosX*eFac,legendPosY*eFac,...
xl*eFac,yl*eFac,eAxesLineWidth*eFac,[0 0 0]);
escalexy(eFile,legendOrientation,...
scalePosX*eFac,scalePosY*eFac,0,0,...
scaleLength*eFac,...
legendScale(1),...
legendScale(2),...
legendScale(3),...
eImageLegendValueFormat,...
eImageLegendVisible,...
eAxesValueFontSize*eFac,...
eAxesLineWidth*eFac,...
eAxesTicShortLength*eFac,...
eAxesTicLongLength*eFac,...
eAxesTicLongMaxN,...
eAxesValueSpace*eFac);
if strcmp(eImageLegendLabelText,'')~=1
etext(eImageLegendLabelText,...
textPosX,...
textPosY,...
eAxesLabelFontSize,0,eAxesLabelTextFont,textAngle);
end
end
|