I am creating a drag box to zoom in that uses the patch
function. I get the following error when I drag:
Error using patch
Not enough input arguments.
Error in boxReady (line 31)
guiele.dragBox = patch(guiele.ResponsePlotAxis, ...
repmat(vabls.CurrentPoint(1,1),[1 4]), ...
repmat(vabls.CurrentPoint(1,2),[1 4]));
Here's the code I'm using:
% This is the point the cursor is at when the user presses down. drawBox is called again
% when the button is released and the current point then is the other corner of the patch
vabls.CurrentPoint = get(guiele.ResponsePlotAxis,'CurrentPoint');
set(guiele.ResponsePlotLine,'erasemode','none');
XYLims=[get(guiele.ResponsePlotAxis,'xlim') get(guiele.ResponsePlotAxis,'ylim')];
axes(guiele.ResponsePlotAxis);
hold on;
if ishandle(guiele.dragBox)
delete(guiele.dragBox);
end
guiele.dragBox = patch(guiele.ResponsePlotAxis, ...
repmat(vabls.CurrentPoint(1,1),[1 4]), ...
repmat(vabls.CurrentPoint(1,2),[1 4]));
set(guiele.dragBox,'FaceColor','none','EdgeColor','r','LineStyle',':');
% initialize some varaiables
guiele.ResponsePlotAxis=-1;
guiele.dragBox = -1;
The three-argument form for patch
(or 4-argument form including an axes handle) requires that you also enter color data for each patch:
patch(X, Y, C);
% Or ...
patch(ax, X, Y, C);
If you don't want to enter color data, you can use the following form:
patch(ax, 'XData', X, 'YData', Y);
So your call to patch
would look something like this:
guiele.dragBox = patch(guiele.ResponsePlotAxis, ...
'XData', repmat(vabls.CurrentPoint(1, 1), [1 4]), ...
'YData', repmat(vabls.CurrentPoint(1, 2), [1 4]));