Merge two plots into one, with the same color

4 次查看(过去 30 天)
I have several lines that are made of two data sets with x,y and x2,y2 ranges that together form a single line.
The thing is that when I try to plot them together they have different colors, so they do not look like a single graph. And as I have to plot many of them, I cannot just set them to be an specific color.
for i=0:50
plot(wavelenght+wavelenght2,integratedvalue+integratedvalue2,'DisplayName',num2str(i)); hold on;
end
I tried to do this, but it did not work. I would like to add the two ranges of values of x and y and plot them like a single line.
  1 个评论
Scott MacKenzie
Scott MacKenzie 2021-6-10
It might help if you provide the complete code that generated the plot and the plot as well.

请先登录,再进行评论。

采纳的回答

Sulaymon Eshkabilov
One of the easy solutions to your exercise is to plot it with this way:
for i=0:50
plot(wavelenght+wavelenght2,integratedvalue+integratedvalue2,'b-','DisplayName',num2str(i)); hold on
end
Or assemble of your data and plot them outside of the loop.

更多回答(1 个)

Surabhi KS
Surabhi KS 2021-6-10
You can specify the color of the plot in your loop.
for i=0:50
plot(wavelenght+wavelenght2,integratedvalue+integratedvalue2,'k--','DisplayName',num2str(i)); hold on;
end

类别

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

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by