Simple xline with all options
242 ビュー (過去 30 日間)
古いコメントを表示
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.
0 件のコメント
回答 (1 件)
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
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
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');
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!