www.gusucode.com > mbcview 工具箱matlab源码程序 > mbcview/@cgsurfview/@lineplot/plot1.m
function plot1(obj,data) %LINEPLOT/PLOT1 Plots a single line for each supplied set of data % % obj.plot1(svdata) % Copyright 2000-2015 The MathWorks, Inc. and Ford Global Technologies, Inc. [values,dsnames] = getAllData(data); for i=1:length(values) % make sure we've got column vectors. tmp = values{i}; values{i} = tmp(:); end points = horzcat(values{:}); points = points'; % each row gives a different line. if getConstraintOptions(data) c = getConstraints(data); points(:,c>0) = NaN; end % X-axis values and limits x = data.getVariableValues(1); x = x(:); x = x'; % make sure we've got row a vector. xlim = mbcmakelimits(x); if any(isfinite(points(:))) set(obj.hAxes,'XLim',xlim,'YLimMode','auto'); obj.hLines = line(x(:),points','Parent',obj.hAxes); xregGui.setLegendData(obj.hLines, dsnames); % Set the user data of the line to be the data set name, so that % we can display it when using cursor mode. for i=1:numel(obj.hLines) set(obj.hLines(i),'UserData',dsnames{i}); end % Refresh legend obj.hLegend = legend(obj.hLines, dsnames(:)); else set(obj.hAxes,'XLim',[-1 1],'YLim',[-1 1]); obj.hText = text('String','No data to plot',... 'Parent',obj.hAxes,... 'FontSize',18,... 'HorizontalAlignment','center'); end % label the X-axis. We have to do this after calling plot. mbcxlabel(obj.hAxes, data.getVariableName(1),'Interpreter','none');