How can I plot the second zoomed plot with legend colour ?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
sanjay Krishnamurthy
el 31 de Mzo. de 2022
Comentada: sanjay Krishnamurthy
el 31 de Mzo. de 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 comentarios
Respuesta aceptada
Chunru
el 31 de Mzo. de 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
Más respuestas (0)
Ver también
Categorías
Más información sobre Data Exploration en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!