adding plot to existing axis, xlim not changing automatically

1 回表示 (過去 30 日間)
David C
David C 2013 年 3 月 21 日
I have a GUI where upon generation a blank plot is generated with AX, H1, and H2 handles
As data is read by reading files obtained from UIGETFILE, I need the GUI to plot them on the existing graph (axes1)
The issue I face now is when I add a plot to the current figure, the x axis doesn't update.
here's what I have:
[AX, H1, H2] = plotyy(0,0,0,0); %generates blank graph
set(get(handles.axes1, 'xlabel'),'string', 'Time'); % x-axis label
hold(AX(1),'on');
hold(AX(2),'on');
% axes formatting
set(AX(1),'YColor',rgb('black'),...
'XLimMode','auto',...
'YLim',[0 25],...
'YTick',(0:5:25));
set(AX(2),'ycolor',rgb('black'),...
'XLimMode','auto',...
'YLim',[0 100],...
'YTick',(0:10:100));
% datetick both axes
datetick(AX(1));
datetick(AX(2));
newgraph1 = plot(AX(1),x,y)
set(newgraph1,'color', [1 1 1])
my newgraph1 plot won't display on the figure, because the initialization of the "blank graph" set the xlim to [-1 1]. When I use get(AX(1)) to see the values, it shows that the 'XLimMode' is set to 'manual' again even though I had originally changed it to 'auto'
Any help is much appreciated, thanks :)
  1 件のコメント
David C
David C 2013 年 3 月 21 日
nevermind, found the solution
set the XLim to start and end of the data being read, then change the XTick accordingly
a manual workaround, but it works fairly well.
If anyone has an alternative solution, i'm all ears :)

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating, Deleting, and Querying Graphics Objects についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by