Different Scales on same plot
2 次查看(过去 30 天)
显示 更早的评论
Attached is the image of a plot I'm willing to generate.
How to show different X Y-axis scales locally to a same plot as shown in figure.
Thank you in advance.
0 个评论
采纳的回答
Sudheer Bhimireddy
2020-8-5
May be give this a try:
z=1:2:100;
y=log(z); % Dummy log profile
h=figure(1);
h.Color=[1 1 1];
subplot(1,5,1)
p1=plot(y,z,'k-o');hold on;
text(-0.5,-5,'0.125'); % This is displayed near the origin
ax1 = gca;box off;
ax1.Position=[0.1 0.2 0.1 0.5];
ax1.XTick=[];ax1.YTick=[]; % Dont label anything
subplot(1,5,2)
p2=plot(y.^0.7,z,'k-o');
hold on;
text(-0.5,-5,'0.250');
ax2 = gca;box off;
ax2.Position=[0.275 0.17 0.1 0.5];
ax2.XTick=[];ax2.YTick=[];
subplot(1,5,3)
p3=plot(-2+y.^1.7,z,'k-o');
hold on;
text(-0.5,-5,'0.375');
ax3 = gca;box off;
ax3.Position=[0.45 0.15 0.1 0.5];
ax3.XTick=[];ax3.YTick=[];
ax3.YAxisLocation='Origin'; %When the x values are -ve this would move the y-axis to x=0
subplot(1,5,4)
p4=plot(-1+y.^0.6,z,'k-o');
hold on;
text(-0.5,-5,'0.500');
ax4 = gca;box off;
ax4.Position=[0.65 0.1 0.1 0.5];
ax4.XTick=[];ax4.YTick=[];ax4.YAxisLocation='Origin';
subplot(1,5,5)
p5=plot(y(1:5),z(1:5),'w');
ax5 = gca;box off;
ax5.Position=[0.74 0.85 0.1 0.1];
xlabel('m/sec');ylabel('cm');
You would have to adjust the number of subplots and axis locations as per your requirement. Another way to control the location is to change the 'Position' property of the subplot itselft. That way you can have subplots without overlapping.
Hope this helps.
2 个评论
Sudheer Bhimireddy
2020-8-5
My pleasure. If you feel you got the answer, please Accept the provided solution as Answer.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Subplots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!