How to add text descriptions to data points in a figure with 3 or more axes?
조회 수: 3 (최근 30일)
이전 댓글 표시
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
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 Center 및 File Exchange에서 Axis Labels에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!