adding plot to existing axis, xlim not changing automatically

1 次查看(过去 30 天)
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 CenterFile Exchange 中查找有关 Creating, 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