필터 지우기
필터 지우기

Merge two plots into one, with the same color

조회 수: 2 (최근 30일)
Jose Cuevas
Jose Cuevas 2021년 6월 10일
답변: Surabhi KS 2021년 6월 10일
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
Sulaymon Eshkabilov 2021년 6월 10일
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