how I show all the numbers in y axes

조회 수: 2(최근 30일)
nourah almalki
nourah almalki 2022년 6월 24일
댓글: Adam Danz 2022년 6월 25일
I want all the numbers to appear. I don't want street line.
clc
clear
close all;
T=[2.12E-5, 2.13E-5, 2.15E-5, 2.33E-5, 3.36E-4, 6.03E-4, 6.11E-4, 6.08E-4, 6.02E-4, 6.07E-4];
S=[2.12E-5, 2.13E-5, 2.13E-5, 2.12E-5, 2.19E-5, 2.27E-5, 2.88E-5, 4.00E-4, 4.10E-4, 4.12E-4];
X=[2.13E-5, 2.13E-5, 2.12E-5, 2.14E-5, 2.15E-5, 2.16E-5, 2.21E-5, 2.31E-5, 2.76E-5, 3.12E-4];
Z=[2.12E-5, 2.13E-5, 2.13E-5, 2.14E-5, 2.14E-5, 2.17E-5, 2.19E-5, 2.27E-5, 2.53E-5, 2.03E-4];
Y=[2.13E-5, 2.11E-5, 2.12E-5, 2.12E-5, 2.15E-5, 2.17E-5, 2.19E-5, 2.27E-5, 2.43E-5, 1.68E-4];
u=200000:200000:2000000;
ax= subplot(1,1,1);
plot(u(1:10),T(1:10),'-o b', 'LineWidth',1.5,'MarkerSize',6)
hold on
plot(u(1:10),S(1:10),'-.o r','LineWidth',1.5,'MarkerSize',6)
plot(u(1:10),X(1:10),'-o m','LineWidth',1.5,'MarkerSize',6)
plot(u(1:10),Z(1:10),'-.o g','LineWidth',1.5,'MarkerSize',6)
plot(u(1:10),Y(1:10),'-o y','LineWidth',1.5,'MarkerSize',6)
grid on
legend('vr=10','vr=15','vr=20','vr=25','vr=30')
xlabel('Messages arrival rate(Messages/s)')
ylabel('Mean responce time(s)')
  댓글 수: 5
nourah almalki
nourah almalki 2022년 6월 24일
This is my problem. I have big project and its important to me that all the numbers appears even these small changes. is there any solution for this problem :( ?

댓글을 달려면 로그인하십시오.

채택된 답변

Voss
Voss 2022년 6월 24일
편집: Voss 2022년 6월 24일
Maybe something along these lines?
clc
clear
close all;
T=[2.12E-5, 2.13E-5, 2.15E-5, 2.33E-5, 3.36E-4, 6.03E-4, 6.11E-4, 6.08E-4, 6.02E-4, 6.07E-4];
S=[2.12E-5, 2.13E-5, 2.13E-5, 2.12E-5, 2.19E-5, 2.27E-5, 2.88E-5, 4.00E-4, 4.10E-4, 4.12E-4];
X=[2.13E-5, 2.13E-5, 2.12E-5, 2.14E-5, 2.15E-5, 2.16E-5, 2.21E-5, 2.31E-5, 2.76E-5, 3.12E-4];
Z=[2.12E-5, 2.13E-5, 2.13E-5, 2.14E-5, 2.14E-5, 2.17E-5, 2.19E-5, 2.27E-5, 2.53E-5, 2.03E-4];
Y=[2.13E-5, 2.11E-5, 2.12E-5, 2.12E-5, 2.15E-5, 2.17E-5, 2.19E-5, 2.27E-5, 2.43E-5, 1.68E-4];
u=200000:200000:2000000;
for ii = [1 2]
ax(ii) = subplot(2,1,ii);
plot(u(1:10),T(1:10),'-o b', 'LineWidth',1.5,'MarkerSize',6)
hold on
plot(u(1:10),S(1:10),'-.o r','LineWidth',1.5,'MarkerSize',6)
plot(u(1:10),X(1:10),'-o m','LineWidth',1.5,'MarkerSize',6)
plot(u(1:10),Z(1:10),'-.o g','LineWidth',1.5,'MarkerSize',6)
plot(u(1:10),Y(1:10),'-o y','LineWidth',1.5,'MarkerSize',6)
grid on
if ii == 1
legend('vr=10','vr=15','vr=20','vr=25','vr=30','Location','NorthWest')
ylabel('Mean response time(s)')
else
xlabel('Message arrival rate (Messages/s)')
end
end
set(ax,'XLim',[0.2 2]*1e6)
set(ax(1),'YLim',[1 7]*1e-4)
set(ax(2),'YLim',[2 3]*1e-5)
set(ax(1),'Position',[0.13 0.33 0.775 0.595],'XTickLabel',{})
set(ax(2),'Position',[0.13 0.11 0.775 0.18])
y_ax = get(ax,'YAxis');
set([y_ax{:}],'Exponent',0)
  댓글 수: 10
Adam Danz
Adam Danz 2022년 6월 25일
Looks like you figured it out 😎

댓글을 달려면 로그인하십시오.

추가 답변(1개)

Adam Danz
Adam Danz 2022년 6월 24일
편집: Adam Danz 2022년 6월 24일
> its important to me that all the numbers appears even these small changes
Is your concern that readers will not believe that the blue, red, purple, and green lines are under the yellow line?
Most of the time it is not necessary to go out of your way to manipulate a visualization to prove that there are a few data points clumped together. This plot is fairly easy to understand that the lines overlap and if you add text that all lines have the same x values, it makes it crystal clear.
But... if you want to see more data.....
You could vary the size of the markers which, in my opinion, doesn't look professional, but you will be able to see the underlying data.
T=[2.12E-5, 2.13E-5, 2.15E-5, 2.33E-5, 3.36E-4, 6.03E-4, 6.11E-4, 6.08E-4, 6.02E-4, 6.07E-4];
S=[2.12E-5, 2.13E-5, 2.13E-5, 2.12E-5, 2.19E-5, 2.27E-5, 2.88E-5, 4.00E-4, 4.10E-4, 4.12E-4];
X=[2.13E-5, 2.13E-5, 2.12E-5, 2.14E-5, 2.15E-5, 2.16E-5, 2.21E-5, 2.31E-5, 2.76E-5, 3.12E-4];
Z=[2.12E-5, 2.13E-5, 2.13E-5, 2.14E-5, 2.14E-5, 2.17E-5, 2.19E-5, 2.27E-5, 2.53E-5, 2.03E-4];
Y=[2.13E-5, 2.11E-5, 2.12E-5, 2.12E-5, 2.15E-5, 2.17E-5, 2.19E-5, 2.27E-5, 2.43E-5, 1.68E-4];
u=200000:200000:2000000;
axes
hold on
plot(u(1:10),T(1:10),'-o b', 'LineWidth',1.5,'MarkerSize',18)
plot(u(1:10),S(1:10),'-.o r','LineWidth',1.5,'MarkerSize',15)
plot(u(1:10),X(1:10),'-o m','LineWidth',1.5,'MarkerSize',12)
plot(u(1:10),Z(1:10),'-.o g','LineWidth',1.5,'MarkerSize',9)
plot(u(1:10),Y(1:10),'-o y','LineWidth',1.5,'MarkerSize',6)
legend('vr=10','vr=15','vr=20','vr=25','vr=30', 'Location','NorthWest')
Or you could keep the markers the same size and use different symbols. This shows that there's data clumped together but it's not easy to read.
figure
hold on
plot(u(1:10),T(1:10),'-* b', 'LineWidth',1.5,'MarkerSize',10)
plot(u(1:10),S(1:10),'-.+ r','LineWidth',1.5,'MarkerSize',10)
plot(u(1:10),X(1:10),'-d m','LineWidth',1.5,'MarkerSize',10)
plot(u(1:10),Z(1:10),'-.s g','LineWidth',1.5,'MarkerSize',10)
plot(u(1:10),Y(1:10),'-o y','LineWidth',1.5,'MarkerSize',10)
legend('vr=10','vr=15','vr=20','vr=25','vr=30', 'Location','NorthWest')
Of course you could plot each line in its own axes using something like a 5x1 tiledlayout but that would prevent direct comparison.
Sometimes people slightly shift the data so you can see more of the data. For example, your curves could be slightlly shifted upward. But most of the time I don't condone that practice because the tick labels then become less meaningful.
Anyone experienced with viewing charts will know that the lines overlap. I suppose there could be a missing data point that would go unnoticed and you'd like to show that no data are missing.
  댓글 수: 4
Adam Danz
Adam Danz 2022년 6월 25일
One could extend @dpb's terrific points to even argue that you shouldn't change the visualization to exaggerate the minutia. There's a concept in the philosophy of data visualization called the lie factor that quantifies the amount of exaggeration (or de-emphasis) applied to the data visualization by the person who created the visualization. Lie factors greater than 1 result from an exaggerated visual effect and values less than 1 result from a demphasis of the visual effect compared to the effect in the data. By magnifying the lower section of your data, your lie factor becomes greater than 1 and could be misleading if readers aren't careful to notice the difference in y-scale between the upper and lower axes. Futhermore, it's nearly impossible for the reader to understand that those values are much much closer than depicted because we can't visually imagine how those lower values would be if they were on the same scale as the rest of the data.
Just some food for thought.

댓글을 달려면 로그인하십시오.

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by