Trying to change colours on the the same plot, but getting error message 'There is no b property on the Line class'

6 次查看(过去 30 天)
I am trying to create a plot which has all of the values negative values below 0 in red, and those positive, above 0 in blue.
However when I try to do this using 'b' for blue and 'r' for red, I am met with the message 'There is no b property on the Line class'
Unsure of where I'm going wrong if someone could please assist
figure((iSubject-2)*100 + (iTest-4)*10 + (iGroup-2))
subplot(511)
plot(acc(:,1))
title('lower back')
positiveIndexes = 2 >= 0;
negativeIndexes = 2 <= 0;
hold on
plot(acc(:,1),(positiveIndexes),'b',1)
plot(acc(:,1),(negativeIndexes),'r',1)

采纳的回答

ME
ME 2019-12-11
The issue with your plotting command is that matlab is interpreting the 'b',1 part as a pair of commands (i.e. ste the property named b equal to 1). At present the 1 won't be doing anything - what was the purpose of the 1?
If you get rid of the ,1 at the end of your plotting command then it will plot in the right colours.

更多回答(1 个)

Cameron Kirk
Cameron Kirk 2019-12-12
Thanks for that, I was trying to mirror a code from someone else, so that one wasn't needed!

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

标签

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by