how I show all the numbers in y axes

29 views (last 30 days)
Nourah
Nourah on 24 Jun 2022
Commented: Adam Danz on 25 Jun 2022
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 Comments
Adam Danz
Adam Danz on 24 Jun 2022
Edited: Adam Danz on 24 Jun 2022
What you see is your data. Your data contain straight lines (ie, a sequence of duplicate or very similar values).
Even if you use a log scale, there still isn't much variation on the left side becuase those values are identical.
% y scale to log
set(gca, 'YScale','log')
Nourah
Nourah on 24 Jun 2022
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 :( ?

Sign in to comment.

Accepted Answer

Voss
Voss on 24 Jun 2022
Edited: Voss on 24 Jun 2022
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 Comments
Adam Danz
Adam Danz on 25 Jun 2022
Looks like you figured it out 😎

Sign in to comment.

More Answers (1)

Adam Danz
Adam Danz on 24 Jun 2022
Edited: Adam Danz on 24 Jun 2022
> 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 Comments
dpb
dpb on 25 Jun 2022
Edited: dpb on 25 Jun 2022
"The readers need to see all the small changes and all the numbers, because they have to judge whether the project is good or not..."
I would contend "judging whether the project is good or not" on the basis of such miniscule differences is a fool's errand; whether a value is 2.12E-5 or 2.33E-5 cannot possibly be of any significance when other values are as much as 30X the value (the "T" vector; others are similar).
What's not been even mentioned here is the Q? of what would these results be if the experiment were to be replicated? Will 2.12 and 2.13 still be precisely 2.12 and 2.13, respectively, or could they be reversed or 2.11 and 2.14? IOW, what's the measurement and other experimental uncertainty here? Can you say there really is any significant difference in any of those nearly-the-same values? Not knowing anything about what these are, my gut feelings would be "not a chance!".
All that could be determined from these data would be something about where the drastic change in magnitude does occur between the various cases and that is quite apparent (at least within the granularity of the data which isn't all that great, either, it would appear).
If, indeed, the point is to illustrate a difference between the cases at the similarly-valued points prior to the quantum change, then change the plot to plot each set of observations by each u value, whatever that is.
Without having a pretty detailed knowledge of what the experiment/project null hypothesis that is being judged is, it's not possible to make any more judgements about the data nor its presentation -- but as others besides me have pointed out, your data are what they are -- manipulating its presentation to make it appear like something besides that is simply not honest science.
If the actual numerc values are real significance, then present them in a table; don't try to make the plot also present absolute numbers; that's not what plots do well; they show trends and comparisons -- the base plot (possibly with a log y-axis) does that just fine; all the other machinations are more distraction than help.
Adam Danz
Adam Danz on 25 Jun 2022
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.

Sign in to comment.

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!