我有一个函数 ParallelPlot 如下:
function ParallelPlot(hAxes, normalizedMatrix )
%//PARALLELPLOT Do Parallel Coordinates Plot for a normalized matrix
%//columns
%// Input:-
%// o hAxes: Handle to an axes.
%// o normalizedMatrix : n-by-m normalized matrix
DEFAULT_AXES_COLOR = [0 0 0];
[MATRIX_HEIGHT MATRIX_WIDTH] = size(normalizedMatrix);
ALL_PLOTS_MATRIX = zeros(MATRIX_HEIGHT,MATRIX_WIDTH);
DEFAULT_MARKER_EDGE_COLOR = [.2 .3 .4];
DEFAULT_MARKER_FACE_COLOR = [.3 .7 .2];
DEFAULT_MARKER_SHAPE = 's';
DEFAULT_MARKER_SIZE = 10;
DEFAULT_MARKER_COLOR = [1 0 0];
DEFAULT_MARKER_LINE_STYLE = '-';
DEFAULT_MARKER_LINE_WIDTH = 1;
SELECTED_MARKER_EDGE_COLOR = [.5 .5 .8];
SELECTED_MARKER_FACE_COLOR = [.4 .4 .6];
SELECTED_MARKER_SHAPE = 'x';
SELECTED_MARKER_SIZE = 15;
SELECTED_MARKER_COLOR = [1 1 1];
SELECTED_MARKER_LINE_STYLE = '--';
SELECTED_MARKER_LINE_WIDTH = 4;
InitializeAllPlotsMatrix;
set(hAxes, 'color', DEFAULT_AXES_COLOR);
set(hAxes,'xLim',[0 MATRIX_WIDTH+1]);
function plotHandle = InitializeNewPlot
plotHandle = plot(hAxes , NaN,NaN );
set(plotHandle, 'Marker' , DEFAULT_MARKER_SHAPE );
set(plotHandle, 'MarkerEdgeColor' , DEFAULT_MARKER_EDGE_COLOR );
set(plotHandle, 'MarkerFaceColor' , DEFAULT_MARKER_FACE_COLOR );
set(plotHandle, 'MarkerSize' , DEFAULT_MARKER_SIZE );
set(plotHandle, 'LineStyle' , DEFAULT_MARKER_LINE_STYLE );
set(plotHandle, 'LineWidth' , DEFAULT_MARKER_LINE_WIDTH );
set(plotHandle, 'Color' , DEFAULT_MARKER_COLOR );
set(plotHandle, 'ButtonDownFcn' , @ParallelPlotButtonDownCallback );
end
function InitializeAllPlotsMatrix
for i = 1 : MATRIX_HEIGHT
for j = 1 : MATRIX_WIDTH
plotHandle = InitializeNewPlot;
hold on;
if j <= MATRIX_WIDTH - 1
xDataValue = [ j j+1];
else
xDataValue = j;
end
if j <= MATRIX_WIDTH - 1
yDataValue = [ normalizedMatrix(i,j) , normalizedMatrix(i,j+1)];
else
yDataValue = normalizedMatrix(i,j);
end
set(plotHandle,'xData', xDataValue,'yData', yDataValue);
ALL_PLOTS_MATRIX(i,j) = plotHandle;
end
end
end
function ParallelPlotButtonDownCallback(plotHandle,eventHandle) %#ok<INUSD>
[i, j] = find(ALL_PLOTS_MATRIX == plotHandle); %#ok<NASGU>
set(ALL_PLOTS_MATRIX, 'Marker' , DEFAULT_MARKER_SHAPE );
set(ALL_PLOTS_MATRIX, 'MarkerEdgeColor' , DEFAULT_MARKER_EDGE_COLOR );
set(ALL_PLOTS_MATRIX, 'MarkerFaceColor' , DEFAULT_MARKER_FACE_COLOR );
set(ALL_PLOTS_MATRIX, 'MarkerSize' , DEFAULT_MARKER_SIZE );
set(ALL_PLOTS_MATRIX, 'LineStyle' , DEFAULT_MARKER_LINE_STYLE );
set(ALL_PLOTS_MATRIX, 'LineWidth' , DEFAULT_MARKER_LINE_WIDTH );
set(ALL_PLOTS_MATRIX, 'Color' , DEFAULT_MARKER_COLOR );
relevantPlotsHandles = ALL_PLOTS_MATRIX(i,:);
set(relevantPlotsHandles, 'Marker' , SELECTED_MARKER_SHAPE );
set(relevantPlotsHandles, 'MarkerEdgeColor' , SELECTED_MARKER_EDGE_COLOR );
set(relevantPlotsHandles, 'MarkerFaceColor' , SELECTED_MARKER_FACE_COLOR );
set(relevantPlotsHandles, 'MarkerSize' , SELECTED_MARKER_SIZE );
set(relevantPlotsHandles, 'LineStyle' , SELECTED_MARKER_LINE_STYLE );
set(relevantPlotsHandles, 'LineWidth' , SELECTED_MARKER_LINE_WIDTH );
set(relevantPlotsHandles, 'Color' , SELECTED_MARKER_COLOR );
end
end
axes()
当我将此函数与空轴(如
plotHandle = plot(hAxes , NaN,NaN );
错误是:
??? Error using ==> set
Invalid handle object.
Error in ==> newplot at 66
set(fig,'nextplot','add');
Error in ==> ParallelPlot>InitializeNewPlot at 37
plotHandle = plot(hAxes , NaN,NaN );
Error in ==> ParallelPlot>InitializeAllPlotsMatrix at 51
plotHandle = InitializeNewPlot;
Error in ==> ParallelPlot at 32
InitializeAllPlotsMatrix;
我不知道为什么会发生这个错误,有人知道如何解决这个问题吗?