Controlling dual axis plots
이전 댓글 표시
Hello all, I have been using a plot involving two y axis plot for a common x axis(just the same units, not the same dataset). I couldn't use plotyy for this because this involves three sets of data for one of the axis(it seems plotyy only works for one set for each axis). Now, I plotted the sets of data as per the steps defined in the help file:
grid on
hl1=line(time,V1,'Color','r');
hl2=line(time,V2,'Color','g');
hl3=line(time,V3,'Color','c');
legend(['one'],['two'],['three']);
ax1=gca;
set(ax1,'XColor','k','YColor','k');
xlabel('time(s)');ylabel('Voltage (V)');
ax2=axes('Position',get(ax1,'Position'),'XaxisLocation',...
'bottom','YaxisLocation','right','Color','none',...
'Xcolor','k','Ycolor','k');
hl2=line(dtime,resistance,'Color','k','Parent',ax2);
legend(['Piezo Sensor'],'location','SouthEast');
title(['Total Voltage summary and piezo response vs time']);
xlabel('time(s)');ylabel('resistance');
First issue is that two legend boxes appear- the left is for axes for the left, and the other for the right. I would like to have them be combined in the same legend box. If they cannot be, I would at least be able to move them- I cannot change the position of the legend box appropriated for the left side.
Second issue is that when I zoom into a certain portion in the graph, I can only zoom into the graph plot in the right axis (not the entire thing).
It seems all of the problems I have been having is due to the code assigning full control to the right side axis. I would like to see and control the plot as one entity, in terms of zooming and legend boxes.
thanks for your help in advance.
sam
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Two y-axis에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!