Simple xline with all options

240 次查看(过去 30 天)
Hagen Übele
Hagen Übele 2021-10-25
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
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.
Steven Lord
Steven Lord 2022-2-2
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');

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Geometric Transformation and Image Registration 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by