필터 지우기
필터 지우기

Using specific color vector in plot

조회 수: 5 (최근 30일)
Kelsey Levine
Kelsey Levine 2019년 5월 7일
답변: Erivelton Gualter 2019년 5월 7일
I am trying to figure out how to plot a line segment using a specific color vector, like [1 0 0]. I typed in the command window plot([0 1], [0 1], 'g') and this plots a green line segment from the point 0,0 to 1,1. However, when I type in the code plot([0 1], [0 1], [1 0 0]), I get the following error message:
Error using plot
Data must be a single matrix Y or a list of pairs X,Y.
I also tried typing in ['1 0 0'] for the color vector and got a different message
Error using plot
Error in color/linetype argument.
I feel like I'm missing something obvious but not sure what it could be. Please help!

채택된 답변

Erivelton Gualter
Erivelton Gualter 2019년 5월 7일
Hi Kelsey,
You need to use the attribute 'color'. See the following example:
plot([0 1], [0 1], 'color', [1 0 0])

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by