a little bug in function "plot/stem"
Show older comments
when you run code:
a = ones(1179080,1);
stem(a)
as shown in figure,you will find the x axis is constant at the end of data.
why?

7 Comments
a = ones(1179080,1);
stem(a(1:100000:end))
a = ones(1179080,1);
stem(a)
ax= gca;
% zoomed x -scale
xlim([1179070 1179080]);
% use ticks
xticks(1179070:1179080);
% then ticklabels
xticklabels(string(1179070:1:1179080));
grid
It seems the DataTip property uses constant (same) values for every 5 units on X scale. E.g demonstration is shown below. When i use values between 1179070 & 1179075 it shows 1179070 but when i change values between 1179076 & 1179080 it displays 1179080. This is inline with that given in documentation page That means it creates a datatip at the nearest data point and perhaps the default property of datatip for plots in Matlab.
datatip(target,x,y) creates a data tip on the 2-D plotted data point specified by x and y. If you specify approximate coordinates, then datatip creates a data tip at the nearest data point.
v = 1179080;
a = ones(v,1);
s = stem(a);
xlim(v-[10,0])
ylim([0.9,1.1])
%
d = datatip(s,1179071,1);
d.X % Confirms correct placement
datatip(s,1179073,1);
datatip(s,1179076,1);
datatip(s,1179080,1);
Accepted Answer
More Answers (0)
Categories
Find more on Creating, Deleting, and Querying Graphics Objects 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!





