Labeling using datetick on a scatter plot?

조회 수: 7 (최근 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 CenterFile Exchange에서 Axis Labels에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by