** UPDATE**
Almost a year later I learned of a way to add text to stackedplot axes. See this answer:
** Original answer showing alternative solution **
I'm assuming you're positioning text according to this screen shot you shared in an earlier question. Since text cannot currently be added to stackedplot axes (as for r2019b, let's hope that changes), here are two workarounds Use an alternative function
(added on 11/19/20)
stackedaxes() on the file exchange is a limited alternative to Matlab's stackedplot and returns the axis handles so that you can add to or modify the plot after it is created. Create your own custom stacked axes
Create axes, link their x-axis limits, and then add text to each axes.
T = table((duration(0,0,17):seconds(1):duration(0,0,20))',...
{'abc','','bcd','cde'}',...
{'test1','','test3','test4'}',...
{'autoserv1','','autoserv3','autoserv4'}',...
'VariableNames',{'WeirdDuration','lot_test','Sublog','Message_test'})
T =
WeirdDuration lot_test Sublog Message_test
_____________ __________ __________ _____________
00:00:17 {'abc' } {'test1' } {'autoserv1'}
00:00:18 {0×0 char} {0×0 char} {0×0 char }
00:00:19 {'bcd' } {'test3' } {'autoserv3'}
00:00:20 {'cde' } {'test4' } {'autoserv4'}
margins = [.11 .11 .08 .12 .01];
height = (1-sum(margins(3:4)) - (nSub-1)*margins(5))/nSub;
width = 1-sum(margins(1:2));
subPos = margins(3):height+margins(5):1;
subHand = arrayfun(@(i)axes(fig,'Position',[margins(1),subPos(i),width,height]),1:nSub);
set(subHand,'XGrid','on')
th = text(subHand(i), x, y, T{:,i+1},'VerticalAlignment','Bottom');
ylim(subHand(i),[min(y),max(y)+1])
xlim(subHand(i),[min(x),max(x)+range(x)*.1])
set(subHand(2:end),'XTickLabel', [])
1 Comment
Direct link to this comment
https://in.mathworks.com/matlabcentral/answers/493926-how-to-stackedplot-with-text-data#comment_773484
Direct link to this comment
https://in.mathworks.com/matlabcentral/answers/493926-how-to-stackedplot-with-text-data#comment_773484
Sign in to comment.