How to insert a graph inside another graph?
Ältere Kommentare anzeigen
I am trying to insert a graph inside an another graph. Can some one tell me how to move the second plot to the empty space on left side and the titel is overlapping with the second graph. My code is as follows:
Z = readtable('Matlab.xlsx') ;
data = table2array(Z) ;
figure(1)
plot(data(:,1), data(:,2), 'ko', 'linewidth', 2);
hold on
plot(data(:,3), data(:,4), 'ks', 'linewidth', 2);
hold on
plot(data(:,5), data(:,6), 'k^', 'linewidth', 2);
hold on
plot(data(:,7), data(:,8), 'kv', 'linewidth', 2);
hold on
plot(data(:,9), data(:,10), 'K', 'linewidth', 2);
hold on
plot(data(:,11), data(:,12), 'kx', 'linewidth', 2);
hold off
ax1 = gca;
legend('P1', 'P2', 'P3','P4','P4', 'P6', 'Location', 'northeastoutside');
grid on
xlim([40 140])
xlabel('x');
ylabel('Y');
ax2 = axes('Position',[.7 .7 .2 .2]);
plot(data(:,13), data(:,14), 'k', 'linewidth', 2);
hold on
plot(data(:,15), data(:,16), 'kx','linewidth', 2);
hold off
grid on
xlim([0 40])
xlabel('x');
ylabel('y');
legend('P7', 'P8', 'Location', 'northeastoutside');
title('[Title on top]')
x0=12;
y0=2;
width=1200;
height=560;
set(gcf,'position',[x0,y0,width,height])
set(gcf,'PaperOrientation','landscape');
4 Kommentare
Walter Roberson
am 6 Okt. 2022
ax2 = axes('Position',[.7 .7 .2 .2]);
You would change that Position .
Note: it is generally tricky to automatically figure out an "empty" space in a plot so it is a lot easier if you do not need it to calculate a "good" position.
Vishnuvardhan Naidu Tanga
am 6 Okt. 2022
Walter Roberson
am 6 Okt. 2022
title(ax1, '[Title on top]')
Vishnuvardhan Naidu Tanga
am 6 Okt. 2022
Antworten (0)
Kategorien
Mehr zu Title finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
