2-d line Plot

2 次查看(过去 30 天)
Martin Thomas
Martin Thomas 2020-8-28
I have to plot a graph,
figure()
plot(x,y)
xlabel('x')
ylabel('y')
But i have to add one more x label in this same plot, it should be like a line under the x axis. How is it possible.?

回答(1 个)

Mehmed Saad
Mehmed Saad 2020-8-28
编辑:Mehmed Saad 2020-8-30
figure,plot(1:10),xlabel({'1st line','2nd line'})

Edit1:

This is one short method (zoom in zoom out) will not work properly
close all
x1 = 11:20;
x2 = 1:10;
y =rand(1,10);
fig = figure(1);
ax2 = axes(fig,'Position',[0.1300 0.1000 0.7750 0.8000]);
plot(x2,y,'Parent',ax2,'Visible','off')
xlim([min(x2),max(x2)]),xlabel('2nd X-Axis','Color','r');
%
ax1 = axes(fig,'Position',[0.1300 0.2000 0.7750 0.7000]);
plot(ax1,x1,y);xlim([11,20]);
xlim([min(x1),max(x1)]),xlabel('1st X-Axis','Color','b');
ax1.XLabel.Position(2) = ax1.YLim(1)-0.05;
ax2.Visible = 'off';
ax2.XAxis.Visible = 'on';
ax2.XAxis.Color = 'r';
ax1.XAxis.Color = 'b';
ax2.XLabel.Position(2) = ax2.YLim(1)-0.05;

类别

Help CenterFile Exchange 中查找有关 Graphics Object Properties 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by