How to add text descriptions to data points in a figure with 3 or more axes?

조회 수: 3 (최근 30일)
bayern science
bayern science 2018년 10월 16일
댓글: Kevin Chng 2018년 10월 16일
Hi all,
I am trying to use 'text' command to add values to date points. The peculiarity of my figure is that it consists of 4 axes plotted by using 'addaxis' command shared in Matlab File Exchange https://www.mathworks.com/matlabcentral/fileexchange/9016-addaxis. In this case 'text' works for the first axis but fails to follow the curves of the remaining axes. Could somebody help to solve this problem? Many thanks!
h = figure;
addpath ./addaxis5
plot(plottime(2:end),numpertime,'k-','LineWidth',1.5);
addaxis(plottime(2:end),numMLCNpertime,'LineWidth',1.5);
addaxis(plottime(2:end),numHKpertime,'LineWidth',1.5);
addaxis(plottime(2:end),numOtherpertime,'LineWidth',1.5);
% add text to the first axis
labels = arrayfun(@(value) num2str(value,'%d'),...
full(numpertime(1:2:end)),'UniformOutput',false);
text(plottime(2:2:end),numpertime(1:2:end),labels,...
'HorizontalAlignment','center',...
'VerticalAlignment','bottom','color','black');
% add text to the second axis
labels = arrayfun(@(value) num2str(value,'%d'),...
full(numMLCNpertime(1:2:end)),'UniformOutput',false);
text(plottime(2:2:end),numMLCNpertime(1:2:end),labels,...
'HorizontalAlignment','center',...
'VerticalAlignment','bottom','color',[0, 0.4470, 0.7410]);
% add text to the third axis
labels = arrayfun(@(value) num2str(value,'%d'),...
full(numHKpertime(1:2:end)),'UniformOutput',false);
text(plottime(2:2:end),numHKpertime(1:2:end),labels,...
'HorizontalAlignment','center',...
'VerticalAlignment','bottom','color',[0.8500, 0.3250, 0.0980]);
% add text to the fourth axis
labels = arrayfun(@(value) num2str(value,'%d'),...
full(numOtherpertime(1:2:end)),'UniformOutput',false);
text(plottime(2:2:end),numOtherpertime(1:2:end),labels,...
'HorizontalAlignment','center',...
'VerticalAlignment','bottom','color',[0.9290, 0.6940, 0.1250]);
  댓글 수: 3
bayern science
bayern science 2018년 10월 16일
Added. Thank you for your attention and suggestion, Kevin!
Kevin Chng
Kevin Chng 2018년 10월 16일
I can't see any error from it. If you could provide your variable for plotting, i will try it out.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

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