So, I played around and managed to find a partial solution based on the type and tag attributes of the lines and texts.
For anyone with the same issue, the following hack works ex post for two orientations (a more generic version would be needed for an arbitrary number of orientations but I scratched my itch).
I believe it would be more elegant to just plot everything as desired ex ante, if this is easy to implement.
Code: Select all
h = get(gca,'Children'); % Get ALL objects
list_types = get(h,'type'); % Get list of types
list_tags = get(h,'tag');
% Find text indexes in h
text_comp = strcmp(list_types,'text'); % Get all types and compare with string 'text'
text_idx = find(text_comp);
% Set indexes for a line with a legend
legend_idx = text_idx + 1;
% Find transitions indexes in h
trans_comp = strcmp(list_tags,'transition'); trans_idx = find(trans_comp);
% Find levels indexes in h
level_comp = strcmp(list_tags,'level'); level_idx = find(level_comp);
htext = findobj(gca,'Type','text'); % Get only text
htrans = findobj(gca,'Tag','transition'); % Get only transitions
hlevels = findobj(gca,'Tag','level'); % Get only levels
for j = 1:length(text_idx)
set(h(text_idx(j)),'Color','w','Linewidth',0.5,'HandleVisibility','off');
end
% Sticks
for jj = trans_idx'
if jj < text_idx(2)
set(h(jj),'linestyle','-','Color',blue,'Linewidth',0.5,'HandleVisibility','off'); %%y
else
set(h(jj),'linestyle','-','Color',green,'Linewidth',0.5,'HandleVisibility','off'); %z
end
end
% Levels
for jj = level_idx'
if jj < text_idx(2)
set(h(jj),'Color',blue,'Linewidth',0.5,'linestyle','-','HandleVisibility','off'); %y
else
set(h(jj),'Color',green,'Linewidth',0.5,'linestyle','-','HandleVisibility','off'); %z
end
end
for jjj = 1:length(legend_idx)
set(h(legend_idx(jjj)),'DisplayName',fliplr(Orientations(jjj)),'HandleVisibility','on')
end