2-d line Plot

3 Ansichten (letzte 30 Tage)
Martin Thomas
Martin Thomas am 28 Aug. 2020
Bearbeitet: Mehmed Saad am 30 Aug. 2020
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.?

Antworten (1)

Mehmed Saad
Mehmed Saad am 28 Aug. 2020
Bearbeitet: Mehmed Saad am 30 Aug. 2020
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;
  1 Kommentar
Martin Thomas
Martin Thomas am 28 Aug. 2020
like this i need

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Line Plots 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!

Translated by