Removing additional points from scatter plot
13 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
How can I removed this additional legend data and keep only 2kw , 3kw and 4 kw and remove additional data points from legend of scatter plot ..Thank you in advance ![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/891215/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/891215/image.png)
The code That i used
A=xlsread('Compare_All_cases','B9:AB9');
i= 1
x1=ones(1,3);
y1=A(:,(i:(i+2)))
hold on
a=scatter(x1,y1,'filled','r')
xtics=[0:1:4];
xticlab={'' '20sec' '35sec' '50sec' ''};
set(gca,'XTick',xtics,'XTickLabel',xticlab,'Fontsize', 10)
text(x1(1),y1(1),sprintf(' (%.1f)[55 55]',y1(1)))
text(x1(2),y1(2),sprintf(' (%.1f)[55 35]',y1(2)))
text(x1(3),y1(3),sprintf(' (%.1f)[35 35]',y1(3)))
i= 4
x2=(ones(1,3)+1);
y2=A(:,(i:(i+2)))
hold on
scatter(x2,y2,'filled','r')
xtics=[0:1:4];
xticlab={'' '20sec' '35sec' '50sec' ''};
set(gca,'XTick',xtics,'XTickLabel',xticlab,'Fontsize', 10)
text(x2(1),y2(1),sprintf(' (%.1f)[55 55]',y2(1)))
text(x2(2),y2(2),sprintf(' (%.1f)[55 35]',y2(2)))
text(x2(3),y2(3),sprintf(' (%.1f)[35 35]',y2(3)))
i= 7
x3=(ones(1,3)+2);
y3=A(:,(i:(i+2)))
hold on
scatter(x3,y3,'filled','r')
xtics=[0:1:4];
xticlab={'' '20sec' '35sec' '50sec' ''};
set(gca,'XTick',xtics,'XTickLabel',xticlab,'Fontsize', 10)
text(x3(1),y3(1),sprintf(' (%.1f)[55 55]',y3(1)))
text(x3(2),y3(2),sprintf(' (%.1f)[55 35]',y3(2)))
text(x3(3),y3(3),sprintf(' (%.1f)[35 35]',y3(3)))
i= 10
x4=(ones(1,3));
y4=A(:,(i:(i+2)))
hold on
scatter(x4,y4,'filled','b')
xtics=[0:1:4];
xticlab={'' '20sec' '35sec' '50sec' ''};
set(gca,'XTick',xtics,'XTickLabel',xticlab,'Fontsize', 10)
text(x4(1),y4(1),sprintf(' (%.1f)[55 55]',y4(1)))
text(x4(2),y4(2),sprintf(' (%.1f)[55 35]',y4(2)))
text(x4(3),y4(3),sprintf(' (%.1f)[35 35]',y4(3)))
i= 13
x5=(ones(1,3)+1);
y5=A(:,(i:(i+2)))
hold on
scatter(x5,y5,'filled','b')
xtics=[0:1:4];
xticlab={'' '20sec' '35sec' '50sec' ''};
set(gca,'XTick',xtics,'XTickLabel',xticlab,'Fontsize', 10)
text(x5(1),y5(1),sprintf(' (%.1f)[55 55]',y5(1)))
text(x5(2),y5(2),sprintf(' (%.1f)[55 35]',y5(2)))
text(x5(3),y5(3),sprintf(' (%.1f)[35 35]',y5(3)))
i= 16
x6=(ones(1,3)+2);
y6=A(:,(i:(i+2)))
scatter(x6,y6,'filled','b')
hold on
xtics=[0:1:4];
xticlab={'' '20sec' '35sec' '50sec' ''};
set(gca,'XTick',xtics,'XTickLabel',xticlab,'Fontsize', 10)
text(x6(1),y6(1),sprintf(' (%.1f)[55 55]',y6(1)))
text(x6(2),y6(2),sprintf(' (%.1f)[55 35]',y6(2)))
text(x6(3),y6(3),sprintf(' (%.1f)[35 35]',y6(3)))
i= 19
x7=(ones(1,3));
y7=A(:,(i:(i+2)))
hold on
scatter(x7,y7,'filled','k')
xtics=[0:1:4];
xticlab={'' '20sec' '35sec' '50sec' ''};
set(gca,'XTick',xtics,'XTickLabel',xticlab,'Fontsize', 10)
text(x7(1),y7(1),sprintf(' (%.1f)[55 55]',y7(1)))
text(x7(2),y7(2),sprintf(' (%.1f)[55 35]',y7(2)))
text(x7(3),y7(3),sprintf(' (%.1f)[35 35]',y7(3)))
i= 22
x8=(ones(1,3)+1);
y8=A(:,(i:(i+2)))
hold on
scatter(x8,y8,'filled','k')
xtics=[0:1:4];
xticlab={'' '20sec' '35sec' '50sec' ''};
set(gca,'XTick',xtics,'XTickLabel',xticlab,'Fontsize', 10)
text(x8(1),y8(1),sprintf(' (%.1f)[55 55]',y8(1)))
text(x8(2),y8(2),sprintf(' (%.1f)[55 35]',y8(2)))
text(x8(3),y8(3),sprintf(' (%.1f)[35 35]',y8(3)))
i= 25
x9=(ones(1,3)+2);
y9=A(:,(i:(i+2)))
hold on
scatter(x9,y9,'filled','k')
xtics=[0:1:4];
xticlab={'' '20sec' '35sec' '50sec' ''};
set(gca,'XTick',xtics,'XTickLabel',xticlab,'Fontsize', 10)
text(x9(1),y9(1),sprintf(' (%.1f)[55 55]',y9(1)))
text(x9(2),y9(2),sprintf(' (%.1f)[55 35]',y9(2)))
text(x9(3),y9(3),sprintf(' (%.1f)[35 35]',y9(3)))
xlim([0 4])
ylabel('CO emissions [mg]')
title ('CO emission for 25 sec after catalyst 1')
legend('2 kW' ,'' ,'' ,'3 kW' ,'','','4 kW')
6 Kommentare
Rik
am 11 Feb. 2022
They all depend on A directly: A(:,i:(i+2)). There is nothing in the code that suggests anything is different. You only use numbered variables, that is the only difference I see.
Apart from the line that defines the value of i and the numbered variables, what is the difference?
Below I have interleave two of the examples you mention. Where exactly is the difference?
i= 1
i= 10
x1=ones(1,3);
x4=(ones(1,3));
y1=A(:,(i:(i+2)))
y4=A(:,(i:(i+2)))
hold on
hold on
a=scatter(x1,y1,'filled','r')
scatter(x4,y4,'filled','b')
xtics=[0:1:4];
xtics=[0:1:4];
xticlab={'' '20sec' '35sec' '50sec' ''};
xticlab={'' '20sec' '35sec' '50sec' ''};
set(gca,'XTick',xtics,'XTickLabel',xticlab,'Fontsize', 10)
set(gca,'XTick',xtics,'XTickLabel',xticlab,'Fontsize', 10)
text(x1(1),y1(1),sprintf(' (%.1f)[55 55]',y1(1)))
text(x4(1),y4(1),sprintf(' (%.1f)[55 55]',y4(1)))
text(x1(2),y1(2),sprintf(' (%.1f)[55 35]',y1(2)))
text(x4(2),y4(2),sprintf(' (%.1f)[55 35]',y4(2)))
text(x1(3),y1(3),sprintf(' (%.1f)[35 35]',y1(3)))
text(x4(3),y4(3),sprintf(' (%.1f)[35 35]',y4(3)))
Antworten (1)
Siehe auch
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!