How to add text descriptions to data points in a figure with 3 or more axes?
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Kevin Chng
am 16 Okt. 2018
I can't see any error from it. If you could provide your variable for plotting, i will try it out.
Antworten (0)
Siehe auch
Kategorien
Mehr zu Axis Labels finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!