How can I plot the second zoomed plot with legend colour ?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
sanjay Krishnamurthy
le 31 Mar 2022
Commenté : sanjay Krishnamurthy
le 31 Mar 2022
The objective here is to have the same legend colour for the zoomed plot [in rectangle box] instead of just blue as shown in the image (second). Can anyone suggest how can i do that? Thank you
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/947279/image.jpeg)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/947359/image.jpeg)
here is my code
clc
clear all
%load the tensile test data
load tensile_matlab.mat
% data variables stored in matrix
X=[AR_e WQ_e AC_e FC_e WQS_e ACS_e FCS_e];
Y=[AR_s WQ_s AC_s FC_s WQS_s ACS_s FCS_s];
plot(X,Y, Linewidth=1.5);
% plot font and legend
legend('AR','WQ','AC','FC','WQ+S','AC+S','FC+S','Location','southeast')
xlabel('Strain')
ylabel('Stress in Mpa')
%second zoom plot
axes('Position',[0.2 0.3 0.45 0.25]);
box on
my_index = 0.04<X & X<0.08;
plot(X(my_index),Y(my_index))
axis tight
0 commentaires
Réponse acceptée
Chunru
le 31 Mar 2022
load tensile_matlab.mat
% data variables stored in matrix
X=[AR_e WQ_e AC_e FC_e WQS_e ACS_e FCS_e];
Y=[AR_s WQ_s AC_s FC_s WQS_s ACS_s FCS_s];
plot(X,Y, Linewidth=1.5);
% whos
% plot font and legend
legend('AR','WQ','AC','FC','WQ+S','AC+S','FC+S','Location','southeast')
xlabel('Strain')
ylabel('Stress in Mpa')
%second zoom plot
h = axes('Position',[0.2 0.3 0.45 0.25]);
box on
%my_index = 0.04<X & X<0.08;
plot(X,Y)
xlim(h, [0.04 0.08])
%axis tight
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Data Exploration dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!