How to add different texts in xline, when using arrayfun ?

3 views (last 30 days)
How to add different texts in xline, when using arrayfun, as in the following example?
% Input and current status
fig = figure();
ax = axes(fig);
ax.XTick = 1:14;
hold on
arrayfun(@(x)xline(x,'-','S','LabelOrientation','horizontal','Color',[.5 .5 .5]), 0:13)
% Desired Output:
  2 Comments
Sim
Sim on 17 Mar 2023
Thanks a lot @Antoni Garcia-Herreros... :-) Actually, I was looking for a little bit "more automatic" way to do so... :-)

Sign in to comment.

Accepted Answer

Star Strider
Star Strider on 17 Mar 2023
Perhaps something like this —
fig = figure();
ax = axes(fig);
ax.XTick = 1:14;
dy = ["S","S","M","T","W","T","F"];
hxl = xline(ax.XTick-1,'-k',repmat(dy,1,fix(max(ax.XTick)/7)), 'LabelOrientation','horiz');
.
  4 Comments
Star Strider
Star Strider on 17 Mar 2023
Thank you for the reference!
I posted an Answer to it.

Sign in to comment.

More Answers (0)

Categories

Find more on Entering Commands in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by