Labeling using datetick on a scatter plot?

8 ビュー (過去 30 日間)
Christopher  Schwarz
Christopher Schwarz 2011 年 9 月 11 日
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

採用された回答

Christopher  Schwarz
Christopher Schwarz 2011 年 9 月 12 日
Nevermind. I figured out the solution. Thanks anyways!
Chris

その他の回答 (1 件)

John Petersen
John Petersen 2012 年 4 月 9 日
You should post the answer.

カテゴリ

Help Center および File ExchangeAxis Labels についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by