adding plot to existing axis, xlim not changing automatically

1 visualización (últimos 30 días)
David C
David C el 21 de Mzo. de 2013
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 comentario
David C
David C el 21 de Mzo. de 2013
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 :)

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Two y-axis en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by