Simple xline with all options

I simply want to add an xline with
a specified position, a specified color, a specified linewidth, a label and a specified label position.
I have tried every pertubation of what I think is possible, but it never works. Best I can achieve is a line with a specified color and a label on the left side. As soon as I try to add a linewidth it only returns invalid parameter/value pair.
It would be very helfpful if somebody could tell me how this is supposed to work.

답변 (1개)

Steven Lord
Steven Lord 2021년 10월 25일

1 개 추천

From the documentation, note that labels comes after the LineSpec but before any name-value pair arguments as stated in the fourth syntax in the Description section.
xline(0.5, 'r--', ... % This is the LineSpec, the label comes next
'$x = \frac{1}{2}$', ... % Only name-value pair arguments after this point
'LineWidth', 3, ...
'Interpreter', 'latex', ...
'LabelOrientation', 'horizontal')

댓글 수: 2

CAME18
CAME18 2022년 2월 2일
Is there any way to have the label with a different color than the line?. For example:
in the example you provided, have the label with black letters instead of red, as the line's color.
There's no ConstantLine property for this, but if you leave the Interpreter property set to 'tex' (the default) you could include \color in your label. See the Interpreter section on this documentation page for a list of the supported markup available for use in TeX labels.
h = xline(0.5, 'r:', ... % line specification
'\color{black}black \color{red}and \color{blue}blue', ... % label text
'LineWidth', 4, ... % name-value pair arguments from this point on
'LabelOrientation', 'horizontal');

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Labels and Annotations에 대해 자세히 알아보기

질문:

2021년 10월 25일

댓글:

2022년 2월 2일

Community Treasure Hunt

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

Start Hunting!

Translated by