漂亮,美观的图表之Matlab强势回归~~~~走你3
来源:互联网 发布:多态java有什么优点 编辑:程序博客网 时间:2024/05/13 00:17
今天我们要学习,如何在figure中添加注释, 并指向方向。
首先画出数据,并添加一条均值线
Line([mean1 mean1], get(gca,’ylim’));
如图:
添加文本连接指向均值线,使用dsxy2figxy从数据空间转换点或位置坐标进入标准的图坐标中,annotation添加图像的注释文本,即指向均值线
function varargout = dsxy2figxy(varargin)if length(varargin{1}) == 1 && ishandle(varargin{1}) ... && strcmp(get(varargin{1},'type'),'axes')hAx = varargin{1};varargin = varargin(2:end); % Remove arg 1 (axes handle)elsehAx = gca;end;% Remaining args are either two point locations or a position vectorif length(varargin) == 1 % Assume a 4-element position vectorpos = varargin{1};else[x,y] = deal(varargin{:}); % Assume two pairs (start, end points)end% Get limitsaxun = get(hAx,'Units');set(hAx,'Units','normalized'); % Make axes units normalized axpos = get(hAx,'Position'); % Get axes positionaxlim = axis(hAx); % Get the axis limits [xlim ylim (zlim)]axwidth = diff(axlim(1:2));axheight = diff(axlim(3:4));% Transform from data space coordinates to normalized figure coordinates if exist('x','var') % Transform a and return pair of pointsvarargout{1} = (x - axlim(1)) * axpos(3) / axwidth + axpos(1);varargout{2} = (y - axlim(3)) * axpos(4) / axheight + axpos(2);else % Transform and return a position rectanglepos(1) = (pos(1) - axlim(1)) / axwidth * axpos(3) + axpos(1);pos(2) = (pos(2) - axlim(3)) / axheight * axpos(4) + axpos(2);pos(3) = pos(3) * axpos(3) / axwidth;pos(4) = pos(4) * axpos(4 )/ axheight;varargout{1} = pos;end% Restore axes unitsset(hAx,'Units',axun)
完整代码:
plot(x,y1);%% Add the |line| at the mean position line([mean1 mean1],get(gca,'ylim'));%% Add the |text arrow| annotation, working from data space annotation% Convert to norm fig units[xmeannfu ymeannfu]= dsxy2figxy(gca,[.5,0],[.15,.05]);% Add the annotation componentannotation('textarrow',xmeannfu,ymeannfu,'String','Mean');title({'The standard normal probability distribution',... ' function is plotted with the mean pointed out with', ... 'a text arrow to make the figure more informative'});xlabel('x');ylabel('probability of x'); set(gcf,'Paperpositionmode','auto','Color',[1 1 1]);
结果图:
- 漂亮,美观的图表之Matlab强势回归~~~~走你3
- 漂亮,美观的图表之Matlab强势回归~~~~走你1
- 漂亮,美观的图表之Matlab强势回归~~~~走你2
- 漂亮,美观的图表之Matlab强势回归~~~~走你4
- 漂亮,美观的图表之Matlab强势回归~~~~走你5
- 漂亮,美观的图表之Matlab强势回归~~~~走你6
- 漂亮,美观的图表之Matlab强势回归~~~~走你7
- 漂亮,美观的图表之Matlab强势回归~~~~走你8
- 漂亮,美观的图表之Matlab强势回归~~~~走你9
- 漂亮的OWC图表
- 强势回归
- 漂亮的JQuery图表插件
- Highcharts:非常漂亮的图表
- HoloGraphLibrary画出漂亮的图表
- Matlab 漂亮的图形
- 暴走大事件,等你回归!
- 强势回归!poj 1950
- Highcharts:十分漂亮的图表API
- pymongo对mongodb进行批量插入以及批量过大出现的问题
- 【Windows7系统开机启动项管理实用技巧】
- Tomcat 配置虚拟主机
- 流行的jQuery Scroll Path plugin
- OpenNI学习笔记1----在vs2010下OpenNI的安装配置
- 漂亮,美观的图表之Matlab强势回归~~~~走你3
- PowerDesigner Name/Code自动调整
- VB数据库连接之二(数据源连接)
- 数组名a 作为 左值和 右值的区别
- 应聘时最漂亮的回答
- 坚持ABC,少年【转载内容】
- 从最大似然到EM算法浅解
- linux:RealVNC安装使用释疑
- 黑马程序员__JAVA基础__面向对象(三)