"plot" and "stairs" in the same figure with different axis
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Andrea Frascella
am 28 Okt. 2018
Kommentiert: madhan ravi
am 28 Okt. 2018
Hello guys, for first excuse me for my bad English. I'm trying to plot in the same figure a graphic with "plot" function and a graphic with "stairs" function to represent the same signal, once analog and once quantized. So, I want to visualize in one figure:
- the analog signal using plot function, X axis at the bottom and Y axis at the left;
- the quantized signal using stairs function, X axis at the top and Y axis at the right;
I tried to specify axis's properties but everytime the output of plot function disappears; in addition to this, I can't display even just stairs function's output with X axis on the top and Y axis on the left.
ax1 = axes('XAxisLocation','bottom','YAxisLocation','left'
ax2 = axes('XAxisLocation','top','YAxisLocation','right');
plot(ax1,P,V_ina)
hold on
stairs(ax2,st,V_adc)
The last command doesn't work in every case. I tried also to specify parent's relationship for stairs function but the code still does not work. Obviously plot and stairs work well together usign "hold on" and the same axis. There is a guide that explains how to do a similiar thing but using only "line" function; can anyone help me? It is really strange that there is a yyaxis funtion and a similiar command for X axis doesn't exist.
2 Kommentare
Akzeptierte Antwort
madhan ravi
am 28 Okt. 2018
Bearbeitet: madhan ravi
am 28 Okt. 2018
x=rand(1,10);
y=1:10;
ax = gca; % current axes
ax1=plot(x,y)
hold on
ax2=stairs(x,y)
ax1=gca;
ax2 = axes('Position', get(ax1, 'Position'),'Color', 'none');
set(ax2, 'XAxisLocation', 'top','YAxisLocation','Right');
5 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Annotations finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!