How to freeze the range of y-axis on an axes on gui?
72 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I am trying to plot the time audio signal using plot(handles.axes1, x) which works fine. The problem is that I cannot make the make the range of a y-axis fix at [-1 1]. I try to set the YLim to be [-1, 1], and YLimMode to be 'manual' both in property windows settings using gui and also in callcall back
0 commentaires
Réponses (3)
Dario Mangoni
le 11 Déc 2018
Modifié(e) : Dario Mangoni
le 11 Déc 2018
Currently (at R2018b) this operation is made easy through 'axis manual' command.
figure;
hold on;
plot(1,1,'+')
plot(2,2,'+')
axis manual
plot(50,50,'+')
The point (50,50) is not in view because axis limits has been retained.
0 commentaires
Matt J
le 28 Août 2015
Modifié(e) : Matt J
le 28 Août 2015
It is not enough to set YLimMode to 'manual'. You need to apply "hold on" as Geoff mentioned. However, you can still use CLA to clear the plot between re-renderings, like in the example below.
axis([0,11,-1,1]);
h=gca;
hold on
h.YLimMode='manual';
for i=1:100,
plot(1:10,rand(1,10));
pause(.3);
drawnow
cla
end
hold off
0 commentaires
Geoff Hayes
le 2 Fév 2015
Try using ylim which will allow you to set the y-axis limits. In your case, you could do something like
ylim(handles.axes1,[-1 1]);
In order to keep these limits, you may need to call
hold(handles.axes1,'on');
so that you return the current properties of the axes before a new plot is added to it.
2 commentaires
Geoff Hayes
le 4 Fév 2015
Why not just replace the x and y data from the previous segment? Something like
% plot the first segment
h = plot(x,y);
% use the handle from plot, h, to update with the new segment data
set(h,'XData',xNewSeg,'YData',yNewSeg);
where xNewSeg and yNewSeg are the x and y data from the new segment.
Voir également
Catégories
En savoir plus sur Geographic Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!