ChaChing 发表于 2009-11-29 20:32

多纵坐标多参数画图

这帖http://forum.vibunion.com/thread-88597-1-1.html引起个人一些兴趣, 搜索了也到官网逛了下, 整理下希望有用!
在"请教高手如何绘制多y 轴的曲线图啊"http://forum.vibunion.com/thread-24244-1-1.html 中,bainhome给的plotyyy, 其原始网址在 http://www.mathworks.com/matlabcentral/fileexchange/1017-plotyyy
新的有注解, 可能较容易看懂! 方便阅读列出如下, 其中所附例子的图亦附上

function = plotyyy(x1,y1,x2,y2,x3,y3,ylabels)
%PLOTYYY - Extends plotyy to include a third y-axis
%
%Syntax: = plotyyy(x1,y1,x2,y2,x3,y3,ylabels)
%
%Inputs: x1,y1 are the xdata and ydata for the first axes' line
%      x2,y2 are the xdata and ydata for the second axes' line
%      x3,y3 are the xdata and ydata for the third axes' line
%      ylabels is a 3x1 cell array containing the ylabel strings
%
%Outputs: ax -   3x1 double array containing the axes' handles
%         hlines - 3x1 double array containing the lines' handles
%
%Example:
%x=0:10;
%y1=x;y2=x.^2;   y3=x.^3;
%ylabels{1}='First y-label';
%ylabels{2}='Second y-label';
%ylabels{3}='Third y-label';
% = plotyyy(x,y1,x,y2,x,y3,ylabels);
%legend(hlines, 'y = x','y = x^2','y = x^3',2)
%
%m-files required: none

%Author: Denis Gilbert, Ph.D., physical oceanography
%Maurice Lamontagne Institute
%Dept. of Fisheries and Oceans Canada
%email: gilbertd@dfo-mpo.gc.ca
%Web: http://www.qc.dfo-mpo.gc.ca/iml/
%April 2000; Last revision: 14-Nov-2001

if nargin==6
   %Use empty strings for the ylabels
   ylabels{1}=' '; ylabels{2}=' '; ylabels{3}=' ';
elseif nargin > 7
   error('Too many input arguments')
elseif nargin < 6
   error('Not enough input arguments')
end

figure('units','normalized',...
       'DefaultAxesXMinorTick','on','DefaultAxesYminorTick','on');

%Plot the first two lines with plotyy
= plotyy(x1,y1,x2,y2);
cfig = get(gcf,'color');
pos = ;
offset = pos(3)/5.5;

%Reduce width of the two axes generated by plotyy
pos(3) = pos(3) - offset/2;
set(ax,'position',pos);

%Determine the position of the third axes
pos3=;

%Determine the proper x-limits for the third axes
limx1=get(ax(1),'xlim');
limx3=;
%Bug fix 14 Nov-2001: the 1.2 scale factor in the line above
%was contributed by Mariano Garcia (BorgWarner Morse TEC Inc)

ax(3)=axes('Position',pos3,'box','off',...
   'Color','none','XColor','k','YColor','r',...   
   'xtick',[],'xlim',limx3,'yaxislocation','right');

hlines(3) = line(x3,y3,'Color','r','Parent',ax(3));
limy3=get(ax(3),'YLim');

%Hide unwanted portion of the x-axis line that lies
%between the end of the second and third axes
line(,,...
   'Color',cfig,'Parent',ax(3),'Clipping','off');
axes(ax(2))

%Label all three y-axes
set(get(ax(1),'ylabel'),'string',ylabels{1})
set(get(ax(2),'ylabel'),'string',ylabels{2})
set(get(ax(3),'ylabel'),'string',ylabels{3})


[ 本帖最后由 ChaChing 于 2009-11-30 09:59 编辑 ]

ChaChing 发表于 2009-11-30 00:42

三纵坐标多参数画图

原先的plotyyy执行多参数时会报错(即当y1/y2/y3为矩阵时), 我稍微修改下!
function = plotyyyM(x1,y1,x2,y2,x3,y3,ylabels)
%PLOTYYY - Extends plotyy to include a third y-axis
%
%Syntax: = plotyyy(x1,y1,x2,y2,x3,y3,ylabels)
%
%Inputs: x1,y1 are the xdata and ydata for the first axes' line
%      x2,y2/x3,y3 are the second/third axes' line
%      ylabels is a 3x1 cell array containing the ylabel strings
%
%Outputs: ax -   3x1 double array containing the axes' handles
%         hlines - nlinex1 double array containing the lines' handles
%
%m-files required: none
%Author: Denis Gilbert, Ph.D., physical oceanography
%Maurice Lamontagne Institute, Dept. of Fisheries and Oceans Canada
%email: gilbertd@dfo-mpo.gc.ca, Web: http://www.qc.dfo-mpo.gc.ca/iml/
%April 2000; Last revision: 14-Nov-2001

if nargin==6, ylabels{1}=' '; ylabels{2}=' '; ylabels{3}=' ';
elseif nargin > 7, error('Too many input arguments')
elseif nargin < 6, error('Not enough input arguments'); end

figure('units','normalized','DefaultAxesXMinorTick','on','DefaultAxesYminorTick','on');
= plotyy(x1,y1,x2,y2); %Plot the first two lines
cfig = get(gcf,'color'); pos = ; offset = pos(3)/5.5;

pos(3) = pos(3)-offset/2; set(ax,'position',pos); %Reduce width of the two axes
pos3=; %the position of the third axes

%Determine the proper x-limits for the third axes
%Bug fix 14 Nov-2001: the 1.2 scale factor in the line above
%was contributed by Mariano Garcia (BorgWarner Morse TEC Inc)
limx1=get(ax(1),'xlim'); limx3=;
ax(3)=axes('Position',pos3,'box','off', 'Color','none','XColor','k', ...
         'YColor','r','xtick',[],'xlim',limx3,'yaxislocation','right');
hlines3 = line(x3,y3,'Color','r','Parent',ax(3));
limy3=get(ax(3),'YLim');

%Hide unwanted portion of the x-axis line that lies
%between the end of the second and third axes
line(,,'Color',cfig,'Parent',ax(3),'Clipping','off');
axes(ax(2))

%Label all three y-axes
set(get(ax(1),'ylabel'),'string',ylabels{1})
set(get(ax(2),'ylabel'),'string',ylabels{2})
set(get(ax(3),'ylabel'),'string',ylabels{3})

hlines = ;
试试下
x=(0:10)'; nn=; nL=length(nn);
y1=x*nn; y2=x.^2*nn; y3=x.^3*nn;
ylabels={'First y-label','Second y-label','Third y-label'};
= plotyyyM(x,y1,x,y2,x,y3,ylabels);
legend(hlines(1:nL),num2str(nn'),2)


[ 本帖最后由 ChaChing 于 2009-11-30 18:43 编辑 ]

ChaChing 发表于 2009-11-30 10:05

四纵坐标ploty4

另还有一个四纵坐标ploty4, 其原始网址在http://www.mathworks.com/matlabcentral/fileexchange/4425
方便阅读列出如下, 其中所附例子的图亦附上
function = ploty4(x1,y1,x2,y2,x3,y3,x4,y4,ylabels)
%PLOTY4   Extends plotyy to include a third and fourth y-axis
%
% Syntax:    = ploty4(x1,y1,x2,y2,x3,y3,x4,y4,ylabels)
%
% Inputs:   x1,y1 are the xdata and ydata for the first axes' line
%         x2,y2 are the xdata and ydata for the second axes' line
%         x3,y3 are the xdata and ydata for the third axes' line
%         x4,y4 are the xdata and ydata for the fourth axes' line
%         ylabels is a 4x1 cell array containing the ylabel strings (optional)
%
% Outputs:ax -      4x1 double array containing the axes' handles
%         hlines -    4x1 double array containing the lines' handles
%
% Example:
%         x = 0:10;
%         y1=x;y2=x.^2;y3=x.^3;y4=x.^4;
%         ylabels{1} = 'First y-label';
%         ylabels{2} = 'Second y-label';
%         ylabels{3} = 'Third y-label';
%         ylabels{4} = 'Fourth y-label';
%          = ploty4(x,y1,x,y2,x,y3,x,y4,ylabels);
%         leghandle = legend(hlines, 'y = x','y = x^2','y = x^3','y = x^4',2);
%
% See also Plot, Plotyy
% Based on plotyyy.m (available at www.matlabcentral.com) by Denis Gilbert, Ph.D.

% Check inputs
msg=nargchk(8,9,nargin); error(msg);

% Create figure window
figure('units','normalized',...
       'DefaultAxesXMinorTick','on','DefaultAxesYminorTick','on');

%Plot the first two lines with plotyy
= plotyy(x1,y1,x2,y2);
cfig = get(gcf,'color'); pos = ; offset = pos(3)/5.5;

%Reduce width of the two axes generated by plotyy
pos(1) = pos(1) + offset; pos(3) = pos(3) - offset;
set(ax,'position',pos);

%Determine the position of the third/fourth axes
pos3 = ;
pos4 = ;

%Determine the proper x-limits for the third and fourth axes
scale3 = pos3(3)/pos(3); scale4 = pos4(3)/pos(3);
limx1 = get(ax(1),'xlim');
limx3 = ;
limx4 = ;

%Create ax(3) & ax(4)
ax(3) = axes('Position',pos3,'box','off',...
   'Color','none','XColor',cfig,'YColor','r',...
   'xtick',[],'xlim',limx3,'yaxislocation','right');
ax(4) = axes('Position',pos4,'box','off',...
   'Color','none','XColor',cfig,'YColor','k',...
   'xtick',[],'xlim',limx4,'yaxislocation','left');

%Plot x3,y3,x4,y4
hlines(3) = line(x3,y3,'Color','r','Parent',ax(3));
hlines(4) = line(x4,y4,'Color','k','Parent',ax(4));

%Put ax(2) on top;
axes(ax(2));

%Set y-labels;
if nargin==9
set(cell2mat(get(ax,{'ylabel'})),{'String'},{ylabels{:}}');
end


[ 本帖最后由 ChaChing 于 2009-11-30 13:27 编辑 ]

ChaChing 发表于 2009-11-30 10:05

四纵坐标多参数画图

与2F相同, 原先的ploty4执行多参数时会报错(即当y1/y2/y3/y4为矩阵时), 我稍微修改下!
function = ploty4(x1,y1,x2,y2,x3,y3,x4,y4,ylabels)
%PLOTY4   Extends plotyy to include a third and fourth y-axis
%
% Syntax:    = ploty4(x1,y1,x2,y2,x3,y3,x4,y4,ylabels)
%
% Inputs:   x1,y1 are the xdata and ydata for the first axes' line
%         x2,y2 are the xdata and ydata for the second axes' line
%         x3,y3 are the xdata and ydata for the third axes' line
%         x4,y4 are the xdata and ydata for the fourth axes' line
%         ylabels is a 4x1 cell array containing the ylabel strings (optional)
%
% Outputs:ax -      4x1 double array containing the axes' handles
%         hlines -    nlinex1 double array containing the lines' handles
%
% See also Plot, Plotyy
% Based on plotyyy.m (available at www.matlabcentral.com) by Denis Gilbert, Ph.D.

% Check inputs
msg=nargchk(8,9,nargin); error(msg);

% Create figure window
figure('units','normalized','DefaultAxesXMinorTick','on','DefaultAxesYminorTick','on');

%Plot the first two lines with plotyy
= plotyy(x1,y1,x2,y2);
cfig = get(gcf,'color'); pos = ; offset = pos(3)/5.5;

%Reduce width of the two axes generated by plotyy
pos(1) = pos(1) + offset; pos(3) = pos(3) - offset;
set(ax,'position',pos);

%Determine the position of the third/fourth axes
pos3 = ;
pos4 = ;

%Determine the proper x-limits for the third and fourth axes
scale3 = pos3(3)/pos(3); scale4 = pos4(3)/pos(3);
limx1 = get(ax(1),'xlim');
limx3 = ;
limx4 = ;

%Create ax(3) & ax(4)
ax(3) = axes('Position',pos3,'box','off',...
   'Color','none','XColor',cfig,'YColor','r',...
   'xtick',[],'xlim',limx3,'yaxislocation','right');
ax(4) = axes('Position',pos4,'box','off',...
   'Color','none','XColor',cfig,'YColor','k',...
   'xtick',[],'xlim',limx4,'yaxislocation','left');

%Plot x3,y3,x4,y4
hlines3 = line(x3,y3,'Color','r','Parent',ax(3));
hlines4 = line(x4,y4,'Color','k','Parent',ax(4));

%Put ax(2) on top;
axes(ax(2));

%Set y-labels;
if nargin==9
set(cell2mat(get(ax,{'ylabel'})),{'String'},{ylabels{:}}');
end
hlines = ;
试试下x=(0:10)'; nn=; nL=length(nn);
y1=x*nn; y2=x.^2*nn; y3=x.^3*nn; y4=x.^4*nn;
ylabels={'First y-label','Second y-label','Third y-label','Fourth y-label'};
= ploty4M(x,y1,x,y2,x,y3,x,y4,ylabels);
legend(hlines(1:nL),num2str(nn'),2)

[ 本帖最后由 ChaChing 于 2009-11-30 18:53 编辑 ]

jhonbilly 发表于 2009-11-30 18:11

回复 楼主 ChaChing 的帖子

顶楼主,好好研究下,正是需要的
关于legend,不写成function,怎么画呢
请教对于线性如何更改,谢谢
楼主的主要是针对函数问题,如果是一些数据呢,对于不同参数的问题,如何应用呢,另外请教线型如果想自定义怎么弄得,谢谢

[ 本帖最后由 ChaChing 于 2009-11-30 18:34 编辑 ]

ChaChing 发表于 2009-11-30 18:59

回复 5楼 jhonbilly 的帖子

上面输入的y1/y2.., 并非针对函数, 而是矩阵数据!
对于不同参数的问题, 个人以为并不合适绘在同一图上, 虽然应该也可以!
每一条line都有对应之handle, 若要改变default, 在legend前先设定好LineStyle/Color/Marker...

还有请善用编辑功能, 方便别人阅读, 否则会有灌水嫌疑!
新手暂不处罚! 拜托下, 很浪费个人时间, 时间花在这处理, 就没空回帖!

自己先试下吧! 要拜肚子了

[ 本帖最后由 ChaChing 于 2010-2-23 08:37 编辑 ]

ChaChing 发表于 2010-1-7 23:26

两个横坐标或两个纵坐标

感觉这个连接使这个更完整
http://www.mathworks.com/matlabcentral/fileexchange/7426
例子可见: 两个横坐标一个纵坐标 http://forum.vibunion.com/thread-83012-1-1.html
function = plot2axes(varargin)
%PLOT2AXES Graphs one set of data with two sets of axes
%
%   PLOT2AXES(X, Y, 'Option1', 'Value1', ...) plots X versus Y with secondary
%   axes.The following options are accepted :
%
%   XLoc ['top']: location of secondary X-axis
%   YLoc ['right']: location of secondary Y-axis
%   XScale : scaling factor for secondary X-axis (scalar)
%   YScale : scaling factor for secondary Y-axis (scalar)
%               
%               XScale and YScale can also be a character string
%               describing the relationship between the 2 axes, such as
%               the equation relating Celsius and Fahrenheit: '5/9*(x-32)'
%
%       Note: PLOT2AXES only works when the relationship is linear.
%             Non-linearly related axes (e.g. 1/x, x^2, etc) do not work.
%
%   XLim : XLim in the primary axes (secondary is adjusted
%                      accordingly). The default is naturally selected by
%                      the plotting function.
%   YLim : YLim in the primary axes (secondary is adjusted
%                      accordingly). The default is naturally selected by
%                      the plotting function.
%
%   PLOT2AXES(@FUN, ...) uses the plotting function @FUN instead of PLOT to
%   produce the plot.@FUN should be a function handle to a plotting
%   function, e.g. @plot, @semilogx, @semilogy, @loglog ,@stem, etc. that
%   accepts the syntax H = FUN(...).Optional arguments accepted by these
%   plotting functions are also allowed (e.g. PLOT2AXES(X, Y, 'r*', ...))
%
%    = PLOT2AXES(...) returns the handles of the primary and
%   secondary axes (in that order) in AX, and the handles of the graphic
%   objects in H.
%
%   The actual data is plotted in the primary axes.The primary axes lie
%   on top of the secondary axes.After the execution of this function,
%   the primary axes become the current axes.If the next plot replaces
%   the axes, the secondary axes are automatically deleted.
%
%   When you zoom in or out using the toolbar, it would only zoom the
%   primary axes, so you should click on the 'Fix Axes' menu at the top of
%   the figure to re-adjust the secondary axes limits.
%
%   PLOT2AXES('FixAxes') fixes the secondary limits of all figures created
%   using plot2axes.
%   
%   Example 1:
%   x = 0:.1:1;
%   y = x.^2 + 0.1*randn(size(x));
%    = plot2axes(x, y, 'ro', 'YScale', 25.4);
%   title('Length vs Time');
%   set(get(ax(1), 'ylabel'), 'string', 'inch');
%   set(get(ax(2), 'ylabel'), 'string', 'millimeter');
%   xlabel('time (sec)');
%
%   Example 2:
%    = plot2axes(x, y, 'ro', 'YScale', '5/9*(x-32)');
%   set(get(ax(1), 'ylabel'), 'string', 'Fahrenheit');
%   set(get(ax(2), 'ylabel'), 'string', 'Celcius');
%
% VERSIONS:
%   v1.0 - first version
%   v1.1 - added option to specify X and Y limits
%   v1.2 - remove tick labels for secondary axes if no scaling factors are
%          specified. Also, fixed bug in matching the scaling type (linear
%          or log).
%   v1.3 - added the 'Fix Axes' menu for adjusting the secondary axes limits
%          after zooming.
%   v1.4 - added the option for specifying an equation for XScale and YScale
%          (June 2005)
%   v1.5 - fixed problem plotting on uipanel, where the parent of the axes
%          is not a figure. (Feb 2006)
%
% Jiro Doke (Inspired by ideas from Art Kuo, Univ of Michigan)
% March 2005
%
if nargin < 1
error('Not enough input arguments');
end
if nargin == 1 && strcmpi(varargin{1}, 'FixAxes')
figsH = findobj('Type', 'figure');
if ~isempty(figsH)
    for iFig = 1:length(figsH)
      p2a = getappdata(figsH(iFig), 'p2a');
      FixAxes([], [], p2a);
    end
end
return;
end
% Default options
options{1} = 'top';       % XLoc
options{2} = 'right';   % YLoc
options{3} = 1;         % XScale
options{4} = 1;         % YScale
options{5} = ;   % XLim
options{6} = ;   % YLim
opts = {'XLoc', ...
    'YLoc', ...
    'XScale', ...
    'YScale', ...
    'XLim', ...
    'YLim'};
var = varargin;
% Check to see if the first argument is a function handle
if isa(var{1}, 'function_handle');
func   = var{1};
var(1) = '';
else
func = @plot;
end
% Parse through input arguments for options
try
removeID = [];
for iVar = 1:length(var)
    if ischar(var{iVar})
      id = strmatch(lower(var{iVar}), lower(opts), 'exact');
      if ~isempty(id)
      options{id} = var{iVar + 1};
      removeID = ;
      end
    end
end
catch
error('Error parsing options.\n%s\n', lasterr);
end
% Verify options
if ~ismember(lower(options{1}), {'top', 'bottom'}) || ...
    ~ismember(lower(options{2}), {'right', 'left'}) || ...
    ~(isnumeric(options{5}) && length(options{5}) == 2) || ...
    ~(isnumeric(options{6}) && length(options{6}) == 2)
error('Bad options');
end
var(removeID) = '';
% Determine the axes to plot
ax1 = newplot;
nextplot = get(ax1, 'NextPlot');
figH = gcf;
% Plot data
try
h = feval(func, var{:});
catch
error('Failed to plot\n%s\n', lasterr);
end
set(ax1, 'Box', 'off', 'Color', 'none');
% Create secondary axes on top of primary axes
ax2 = axes(...
'Position', get(ax1, 'Position'), ...
'Box'   , 'off', ...
'Parent', get(ax1, 'Parent'));
%--------------------------------------------------------------------------
% Apply options
%--------------------------------------------------------------------------
if strcmpi(options{1}, 'top') % XLoc
set(ax1, 'XAxisLocation', 'bottom');
set(ax2, 'XAxisLocation', 'top');
else
set(ax1, 'XAxisLocation', 'top');
set(ax2, 'XAxisLocation', 'bottom');
end
if strcmpi(options{2}, 'right') % YLoc
set(ax1, 'YAxisLocation', 'left');
set(ax2, 'YAxisLocation', 'right');
else
set(ax1, 'YAxisLocation', 'right');
set(ax2, 'YAxisLocation', 'left');
end
if ~all(isnan(options{5}))% XLim
set(ax1, 'XLim', options{5});
end
if ~all(isnan(options{6}))% YLim
set(ax1, 'YLim', options{6});
end
if ischar(options{3}) % for functional relationship
tmp = inline(options{3});
set(ax2, 'XLim', fliplr(tmp(get(ax1, 'XLim'))),'Xdir','reverse');
%set(ax2, 'XLim', tmp(get(ax1, 'XLim')));
else
set(ax2, 'XLim', get(ax1, 'XLim') * options{3})
end
if ischar(options{4})
tmp = inline(options{4});
set(ax2, 'YLim', tmp(get(ax1, 'YLim')));
else
set(ax2, 'YLim', get(ax1, 'YLim') * options{4})
end
set(ax2, 'XScale', get(ax1, 'XScale'), ...
'YScale', get(ax1, 'YScale'));
if options{3} == 1 % if there is no scaling, remove tick labels
set(ax2, 'XTickLabel', '');
end
if options{4} == 1 % if there is no scaling, remove tick labels
set(ax2, 'YTickLabel', '');
end
%--------------------------------------------------------------------------
% Create DeleteProxy objects (an invisible text object) so that the other
% axes will be deleted properly.<inspired by PLOTYY>
%--------------------------------------------------------------------------
DeleteProxy(1) = text(...
'Parent'          , ax1, ...
'Visible'         , 'off', ...
'HandleVisibility', 'off');
DeleteProxy(2) = text(...
'Parent'          , ax2, ...
'Visible'         , 'off', ...
'HandleVisibility', 'off', ...
'UserData'      , DeleteProxy(1));
set(DeleteProxy(1), ...
'UserData'      , DeleteProxy(2));
set(DeleteProxy, ...
'DeleteFcn'       , @DelFcn);
%--------------------------------------------------------------------------
% Switch the order of axes, so that the secondary axes are under the
% primary axes, and that the primary axes become the current axes.
%--------------------------------------------------------------------------
% get list of figure children. ax1 and ax2 must exist in this list
ch = get(get(ax1, 'Parent'), 'Children');
i1 = find(ch == ax1);       % find where ax1 is
i2 = find(ch == ax2);       % find where ax2 is
ch() = ;% swap ax1 and ax2
% assign the new list of children and set current axes to primary
set(get(ax1, 'Parent'), 'Children', ch);
set(figH, 'CurrentAxes', ax1);
% Restore NextPlot property (just in case it was modified)
set(, 'NextPlot', nextplot);
% Store axes information
p2a = getappdata(figH, 'p2a');
if isempty(p2a)
p2a = {};
end
p2a = ;
setappdata(figH, 'p2a', p2a);
% Create 'Fix Axes' button for adjusting the secondary axes limits after
% zooming
hMenu = findobj(figH, 'Type', 'uimenu', 'Label', 'Fix Axes');
if strcmpi(get(figH, 'Menubar'), 'figure') && ...
    (isempty(hMenu) || ~ishandle(hMenu))
uimenu(...
    'Parent', figH, ...
    'Label'   , 'Fix Axes', ...
    'Callback', @FixAxes);
end
if nargout
ax = ;
end
%--------------------------------------------------------------------------
% DelFcn - automatically delete both axes
%--------------------------------------------------------------------------
function DelFcn(obj, edata)
try
set(get(obj, 'UserData'), ...
    'DeleteFcn', 'try;delete(get(gcbo, ''UserData''));end');
set(obj, 'UserData', ...
    get(get(obj, 'UserData'), 'Parent'));
delete(get(obj,'UserData'));
end

%--------------------------------------------------------------------------
% FixAxes - fix the scaling of the axes
%--------------------------------------------------------------------------
function FixAxes(obj, edata, p2a)
if nargin < 3
p2a = getappdata(get(obj, 'Parent'), 'p2a');
end
if ~isempty(p2a)
for iAx = 1:size(p2a, 1)
    if ishandle(p2a{iAx, 1}) && ishandle(p2a{iAx, 2})
      if ischar(p2a{iAx, 3})
      tmp = inline(p2a{iAx, 3});
      set(p2a{iAx, 2}, 'XLim', tmp(get(p2a{iAx, 1}, 'XLim')));
      else
      set(p2a{iAx, 2}, 'XLim', p2a{iAx, 3} * get(p2a{iAx, 1}, 'XLim'));
      end
      if ischar(p2a{iAx, 4})
      tmp = inline(p2a{iAx, 4});
      set(p2a{iAx, 2}, 'YLim', tmp(get(p2a{iAx, 1}, 'YLim')));
      else
      set(p2a{iAx, 2}, 'YLim', p2a{iAx, 4} * get(p2a{iAx, 1}, 'YLim'));
      end
    end
end
end

[ 本帖最后由 ChaChing 于 2010-8-10 14:49 编辑 ]

hxzslkm 发表于 2010-5-15 22:51

我今天是到处找资料研究这个弄半天了,就是要搞多纵坐标,而且要把坐标重合在一起,这篇帖子太及时了...
由衷感谢!!!!

vehicle 发表于 2011-4-2 16:07

太厉害了!!!!!

zhengyangxue 发表于 2011-4-3 09:52

这个资料好啊,我正愁怎么弄呢

zhenzhy 发表于 2011-4-7 14:13

很全面啊

chkxuan 发表于 2011-12-19 15:52

太感谢了

mingmingtree 发表于 2012-3-29 17:05

太强大了!先留着,慢慢学。
我想沿着横坐标延伸的方向连续绘四个高斯脉冲,用的是同一个高斯分布函数来生成,只是四个峰的高矮胖瘦不全相同,因此要设置每个高斯脉冲函数的参数,并且要把各个y与x对应的点一一保存为txt。我的程序如下,为何plot只显示第二个峰还没有第一个峰呢(程序里暂时只设置了两个峰,打算以后再弄四个)?
function []=gs02()
%diary gs2901.txt
a = 1;
b1 = 1513;b2=1535;
c1 = 0.3;c2=0.2;
g1 = @(t)a*exp(-4*log2((t-b1)/c1).^2);
g2 = @(t)a*exp(-4*log2((t-b2)/c2).^2);
x = 1513:0.005:1550;
y1 = g1(x);
y2=g2(x);
plot(x,y1,'-*')
plot(x,y2,'-*')
xlabel('wavelength'),ylabel('guangqiang');
dlmwrite('datademo1.txt',,'newline','pc');
dlmwrite('datademo2.txt',,'newline','pc');

mingmingtree 发表于 2012-3-30 16:50

回复 13 # mingmingtree 的帖子

囧~就是想请教,当时看到这个页面,竟然不知不觉就到这了。{:{28}:}

ChaChing 发表于 2012-3-31 01:27

回复 14 # mingmingtree 的帖子

不要紧, 我晓得谢老师与LS好像解决了!
页: [1] 2
查看完整版本: 多纵坐标多参数画图