声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 10517|回复: 25

[绘图技巧] 请教高手如何绘制多y 轴的曲线图啊

[复制链接]
发表于 2006-9-2 16:03 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
请教高手如何绘制多y 轴的曲线图啊
回复
分享到:

使用道具 举报

发表于 2006-9-2 16:17 | 显示全部楼层
help plotyy
 楼主| 发表于 2006-9-2 16:19 | 显示全部楼层

那只是双y轴吧?

那只是双y轴吧?
发表于 2006-9-2 16:35 | 显示全部楼层
原帖由 bill0301 于 2006-9-2 16:19 发表
那只是双y轴吧?

还是把具体问题写出来比较好,这样别人也好理解一些
发表于 2006-9-3 08:20 | 显示全部楼层
你说的多y轴是什么意思,能否详细说明一下
 楼主| 发表于 2006-9-3 09:31 | 显示全部楼层
x = [0 0.1 0.2 0.3 0.4 0.426 0.5 0.6 0.688 0.7 0.8 0.9 1.0];
y = [268.95 272.36 275.07 277.07 277.93 278 276.5 267.16 248.2 244.3 200.37 137.71 58.7];
a = [0 0.225 0.408 0.566 0.693 0.718 0.776 0.82 0.831 0.831 0.818 0.784 0.6];
k = [2.55 2.254 2.063 1.886 1.733 1.687 1.552 1.368 1.207 1.187 1.023 0.873 0.6];

以x为横坐标其余为纵坐标画在一个图里面

请教怎么发送图片啊我把图片发上来就明白了啊
在这个图上采用3种坐标比例

[ 本帖最后由 ChaChing 于 2009-11-28 23:40 编辑 ]
发表于 2006-9-3 09:56 | 显示全部楼层
原帖由 bill0301 于 2006-9-3 09:40 发表
请教怎么发送图片啊我把图片发上来就明白了啊


上传图片就行,和上传附件一样
 楼主| 发表于 2006-9-3 10:27 | 显示全部楼层
谢谢,不过我还不知道在哪上传附件啊
发表于 2006-9-3 10:28 | 显示全部楼层
原帖由 bill0301 于 2006-9-3 10:27 发表
谢谢,不过我还不知道在哪上传附件啊


看帖子http://forum.vibunion.com/forum/thread-23571-1-1.html
发表于 2006-9-3 11:12 | 显示全部楼层
原帖由 bill0301 于 2006-9-3 09:31 发表
x = ;
y = ;
a = ;
k = ;

以x为横坐标其余为纵坐标画在一个图里面


那有一个Y坐标显示不了了?是吧。
发表于 2006-9-3 11:14 | 显示全部楼层
Get this M file from FileExchange in mathworks website
  1. function [ax,hlines] = plotyyy(x1,y1,x2,y2,x3,y3,ylabels)
  2. %PLOTYYY - Extends plotyy to include a third y-axis
  3. %Syntax:  [ax,hlines] = plotyyy(x1,y1,x2,y2,x3,y3,ylabels)
  4. %Inputs: x1,y1 are the xdata and ydata for the first axes' line
  5. %        x2,y2 are the xdata and ydata for the second axes' line
  6. %        x3,y3 are the xdata and ydata for the third axes' line
  7. %        ylabels is a 3x1 cell array containing the ylabel strings
  8. %Outputs: ax -     3x1 double array containing the axes' handles
  9. %         hlines - 3x1 double array containing the lines' handles
  10. %Author: Denis Gilbert, Ph.D., physical oceanography
  11. %Maurice Lamontagne Institute
  12. %Dept. of Fisheries and Oceans Canada
  13. %email: gilbertd@dfo-mpo.gc.ca  
  14. %Web: http://www.qc.dfo-mpo.gc.ca/iml/
  15. %April 2000; Last revision: 14-Nov-2001
  16. if nargin==6
  17.    ylabels{1}=' '; ylabels{2}=' '; ylabels{3}=' ';
  18. elseif nargin > 7
  19.    error('Too many input arguments')
  20. elseif nargin < 6
  21.    error('Not enough input arguments')
  22. end
  23. figure('units','normalized',...
  24.        'DefaultAxesXMinorTick','on','DefaultAxesYminorTick','on');
  25. [ax,hlines(1),hlines(2)] = plotyy(x1,y1,x2,y2);
  26. cfig = get(gcf,'color');
  27. pos = [0.1  0.1  0.7  0.8];
  28. offset = pos(3)/5.5;
  29. pos(3) = pos(3) - offset/2;
  30. set(ax,'position',pos);  
  31. pos3=[pos(1) pos(2) pos(3)+offset pos(4)];
  32. limx1=get(ax(1),'xlim');
  33. limx3=[limx1(1)   limx1(1) + 1.2*(limx1(2)-limx1(1))];
  34. ax(3)=axes('Position',pos3,'box','off',...
  35.    'Color','none','XColor','k','YColor','r',...   
  36.    'xtick',[],'xlim',limx3,'yaxislocation','right');
  37. hlines(3) = line(x3,y3,'Color','r','Parent',ax(3));
  38. limy3=get(ax(3),'YLim');
  39. line([limx1(2) limx3(2)],[limy3(1) limy3(1)],...
  40.    'Color',cfig,'Parent',ax(3),'Clipping','off');
  41. axes(ax(2))
  42. set(get(ax(1),'ylabel'),'string',ylabels{1})
  43. set(get(ax(2),'ylabel'),'string',ylabels{2})
  44. set(get(ax(3),'ylabel'),'string',ylabels{3})
复制代码

=============================================================================
run code shown as below in "Command Window"
  1. x = [0 0.1 0.2 0.3 0.4 0.426 0.5 0.6 0.688 0.7 0.8 0.9 1.0];
  2. y = [268.95 272.36 275.07 277.07 277.93 278 276.5 267.16 248.2 244.3 200.37 137.71 58.7];
  3. a = [0 0.225 0.408 0.566 0.693 0.718 0.776 0.82 0.831 0.831 0.818 0.784 0.6];
  4. k = [2.55 2.254 2.063 1.886 1.733 1.687 1.552 1.368 1.207 1.187 1.023 0.873 0.6];
  5. ylabels{1}='轴1';
  6. ylabels{2}='轴2';
  7. ylabels{3}='轴3';
  8. [ax,hlines] = plotyyy(x,y,x,a,x,k,ylabels);
  9. legend(hlines, 'y = x','a =x','k = x',2)
复制代码

Relative Figure shown as below:
figyyy.jpg

[ 本帖最后由 bainhome 于 2006-9-3 11:17 编辑 ]

评分

1

查看全部评分

发表于 2006-9-3 11:29 | 显示全部楼层
这个方法解决得好,绘制出3条曲线容易,可是给出第3个y轴的刻度就不好办了,我还在想呢,答案就给出来了^_^
 楼主| 发表于 2006-9-3 17:29 | 显示全部楼层
对就是这个意思,谢谢了,不过那个编程太长够让我头疼的了啊,
还有在这个图上能不能找到任意一点的 坐标啊

[ 本帖最后由 ChaChing 于 2009-11-28 23:43 编辑 ]
发表于 2006-9-3 18:55 | 显示全部楼层
This function made by Genial
  1. function hc
  2. ezplot('sin(x)');  
  3. set(gcf,'pointer','cross');  
  4. set(gcf,'WindowButtonMotionFcn',@tempfcn2);  
  5.   
  6. function tempfcn2(hObject, eventdata, handles)  
  7. p=get(gca,'currentpoint');  
  8. if(isempty(findobj('tag','htext')))  
  9.    ht=text('tag','htext','string',sprintf('(%g, %g)', p(1), p(3)),'position',[p(1),p(3)]);  
  10. else  
  11.    ht = findobj('tag','htext');  
  12.    set(ht,'string',sprintf('(%g, %g)', p(1), p(3)),'position',[p(1),p(3)]);  
  13. end
复制代码

[ 本帖最后由 bainhome 于 2006-9-3 20:40 编辑 ]

评分

1

查看全部评分

 楼主| 发表于 2006-9-3 22:20 | 显示全部楼层
太强了啊,虽然看不懂,但是非常的感谢
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-5-14 23:59 , Processed in 0.156833 second(s), 26 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表