color plotting error appearing only after one line and not appearing earlier

6 次查看(过去 30 天)
The second line of the fragment of code below throws an error. Does anyone have any idea why? I was able to plot just fine yesterday so I'm not sure what could be going on
plot(sulpholane9a(end-1000:20:end,1)*10^-6, sulpholane9a(end-1000:20:end,3)*10^9, '>','Color','b', 'LineWidth',1)%c(35,:))
hold on
plot(nitromethane11a(end-1000:20:end,1)*10^-6, nitromethane11a(end-1000:20:end,3)*10^9,'+','Color',c(45,:),'LineWidth',1)
hold on
plot(water2a(end-1000:20:end,1)*10^-6, water2a(end-1000:20:end,3)*10^9,'square','Color',c(65,:),'LineWidth',1)
Error using plot
Invalid RGB triplet. Specify a three-element vector of values between 0 and 1.
  1 个评论
Dyuman Joshi
Dyuman Joshi 2023-8-18
What is the range of the values in and size of the array c?
As the error states, the values must be a 3 element vector with values between 0 and 1.

请先登录,再进行评论。

回答(1 个)

Shuba Nandini
Shuba Nandini 2023-8-29
Hello,
I understand you are getting color plotting error in your code using variable ‘c’.
The error message you're seeing "Invalid RGB triplet. Specify a three-element vector of values ranging from 0 and1" suggests that there might be a problem with how you specified the color in one of your plot commands.
  • If you prefer to use predefined MATLAB colors, you can simply use color names such, as 'b', 'r', 'g' without specifying the RGB values as you have specified it in this plot command.
plot(sulpholane9a(end-1000:20:end,1)*10^-6, sulpholane9a(end-1000:20:end,3)*10^9, '>','Color','b', 'LineWidth',1)
You can also refer to the follwoing thread to know how this error is resolved:
I hope this helps!
Regards,
Shuba Nandini

类别

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

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by