很常用的两个小函数,希望大家可以收藏。
hline和vline函数在当前坐标轴上的指定位置绘制水平线或垂直线。
These functions draw horizontal or verticallines at specified places on the current axes.
function hhh=vline(x,in1,in2)
% function h=vline(x, linetype, label)
% 在当前坐标轴上,以变量x指定的位置绘制垂直线。
% ‘linetype’(默认为’r’)和’label’为可选参数,应用于直线旁边的文本标签属性。
% 标签与直线的颜色相同。
% Draws a vertical line on the current axesat the location specified by ‘x’. Optional arguments % are ‘linetype’ (default is ‘r:’) and ‘label’, whichapplies a text label to the graph near the line.
% The label appears in the same color asthe line.
%
% 直线绘制结果在当前坐标轴下一直保持,在画线结束后,函数再返回以前的坐标轴状态。
% The line is held on the current axes, andafter plotting the line, the function returns the axes to
% its prior hold state.
% 直线的HandleVisibility属性设置为“off”,因此不仅不会显示在图例上,而且用findobj也是无法找到的。可以对直线指定一个返回的输出句柄,这样方便使用或删除。当ShowHiddenHandles属性设定为on时,HandleVisibility的设置将会被否决,即ShowHiddenHandles属性的优先级高于HandleVisibility。
% The HandleVisibility property of the lineobject is set to “off”, so not only does it not appear on
% legends, but it is not findable by usingfindobj. Specifying an output argumentcauses the
% function to return a handle to the line,so it can be manipulated or deleted. Also, the
% HandleVisibility can be overridden by settingthe root’s ShowHiddenHandles property to on.
% 函数使用举例
% h = vline(42,‘g’,‘The Answer’)
……
源码下载地址:
http://page2.dfpan.com/fs/8lc6j2621c29116f7d7/
更多精彩文章请关注微信号: