How to rotate xline label with vertical orientation?

26 views (last 30 days)
Hello, in my figure I have a xline with a label. The orientation of this label is vertical and can be read from the bottom to the top of the figure. I need a rotated label, always in a vertical orientation but readable from the top to the bottom. Is it possible?
Many thanks,
Sofia

Accepted Answer

Shivam
Shivam on 5 Sep 2024
Hi Sofia,
You can follow the workaround mentioned to get the text label in vertical orientation but readable from the top to the bottom.
% Add an xline
xlinePosition = 5; % Example position for the xline
xline(xlinePosition, 'Color', 'r', 'LineWidth', 2);
% Add a custom text label for the xline
labelText = 'My Label';
% Adjust y position and 'VerticalAlignment' as needed
text(xlinePosition, max(y), labelText, 'Rotation', -90, ...
'VerticalAlignment', 'bottom', 'HorizontalAlignment', 'left');
You can make the position adjustments of the line and text label according to your needs.
I hope it is helpful.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!