Can I change the color of the label in xline / yline to be different from the color of the line?
114 次查看(过去 30 天)
显示 更早的评论
I want the label color (i.e., of the text) to be a different color than the line color in xline and/or yline.
Is there an easy way to do this without the workaround below?
xline(5, '-', 'Text');
hold on;
xline(5, '-g');
hold off;
7 个评论
Adam Danz
2023-9-11
移动:Dyuman Joshi
2024-10-10
> The need is to make xlines and ylines...have lower contrast with the plot background color while having the label of the line have high contrast so the viewer can easily read it.
To achieve that, lower the Alpha value of the ConstantLine objects. This won't affect the label.
plot(peaks,'k-')
xline(10,'-k','Default Alpha')
xline([20:10:40], '-k', 'Lower alpha','Alpha',0.2)
采纳的回答
Afiq Azaibi
2024-10-4
Starting in R2024b, you can leverage the LabelColor property on ConstantLine to control the color of the label independently of the line.
x = xline(3, 'r', 'some label');
x.LabelColor = 'k';
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Labels and Annotations 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!