Labeling using datetick on a scatter plot?
1 view (last 30 days)
Show older comments
Hello,
I am trying to do a scatter plot with labels of each point's value. The trick here is using datenum to get values for the x-axis using datetick. Prior to this I just used a for loop to obtain the position of each point, and num2str(...) for each point's numerical quantity. However, using datenum/datetick, the code below does not properly identify the position of each point properly.
Example:
f3=figure(3);
set(f3,'Units','normalized','Position',[0.1 0.1 0.65 0.85]);
h5=scatter(dnums,NOXPHghtMeso2,TimeOnes2,NOXPVortM2,'filled');
datetick('x',13)
h6=colorbar('peer',gca);
set(get(h6,'ylabel'),'String','x 10^-^3 ','Fontweight','bold','FontSize',12)
hold on
for idx2=1:max(size(NOXPTimeM2))
text(dnums(idx2),NOXPHghtMeso2(idx2)+0.05,num2str(NOXPVortM2(idx2)))
end
hold off
%where dnums is calculated from:
for idx=1:max(size(NOXPHghtMeso2))
tmp_str=char(num2str(NOXPHghtMeso2(idx)));
if(idx>1)
if(M2hrs(idx)<M2hrs(idx-1))
day=day+1;
end
end
dvec=[2010 05 day M2hrs(idx) M2min(idx) M2sec(idx)];
dnums(idx)=datenum(dvec);
end
I have been struggling to figure out a conversion that the plot will recognize to line up the x-position with datetick, but nothing comes to mind. Is there a means of doing this?
Thanks,
Chris
0 Comments
Accepted Answer
More Answers (1)
See Also
Categories
Find more on Annotations 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!