color plot arguments questions
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
Hello ,what is the role of 'color' and col(d,:) arguments in the plot command?
plot(phi, eta * abs(J), 'color', col(d,:));
I couldnt find in the syntax bellow this pattern.
Thanks

채택된 답변
Steven Lord
2019년 5월 10일
1 개 추천
That is using the plot(___,Name,Value) syntax where ___ is replaced by phi, eta * abs(J). 'Color' is listed in the Name-Value Pair Arguments subsection of the Input Arguments section on the plot documentation page and col(d,:) is the value for that name.
Look at the "Add Title and Axis Labels" example on the plot documentation page for a demonstration of that syntax. In that case the RGB value used to color the line is [0, 0.7, 0.9] -- no red, a lot of green, and even more blue makes the line blue-green.
댓글 수: 7
fima v
2019년 5월 10일
"hat is using the plot(___,Name,Value) syntax where ___ is replaced by phi, eta * abs(J). 'Color' is listed in the Name-Value Pair Arguments subsection of the Input Arguments section on the plot documentation page and col(d,:) is the value for that name."
could you please give a simpler example so i will see the role of each one?
Thanks.
v = 1:10;
plot(v, v.^2, 'Color', 'red', 'Marker', 'pentagram')
This plots a line with points (1, 1), (2, 4), (3, 9), etc. up through (10, 100). The x coordinates of the points are the first input to plot, v. The y coordinates of the points are the second input, v.^2, which squares each element in v.
The last four arguments are taken in pairs, a Name followed by a Value.
'Color', 'red' tells MATLAB to plot the line red. 'Color' is the Name for this pair of arguments and 'red' is the Value.
'Marker', 'pentagram' tells MATLAB to plot the markers for the points using five pointed stars (pentagrams.)
Using the Name and Value pairs you can set properties of the line as it's being plotted, rather than having it be plotted using the default values then have its properties change. More likely than not the line's color or markers changing would be too quick for you to notice, but it could cause the plot to flicker. Better to set them to your desired values from the start.
fima v
2019년 5월 10일
Hello , so in my case the last argument "col(d,:)" its not a sinle value we have ":"
which means that it takes all values of second argument of "col" so its a vector?
what is the meaning of this when setting the color type?
Thanks
plot(phi, eta * abs(J), 'color', col(d,:));
Steven Lord
2019년 5월 10일
According to the documentation the Value for the 'Color' Name argument can be "specified as an RGB triplet, a hexadecimal color code, a color name, or a short name."
When I specified 'red' in my plot call I used the color name. Your code, assuming the col matrix has three columns, specifies an RGB triplet. In my plot call I could have used 'r' (the short name for red) or [1 0 0] (the RGB triplet for red) instead of 'red'.
There are eight colors that you can specify using color names or short names: red, green, blue, cyan, magenta, yellow, black, and white. If you want a different color you're going to want to use its RGB triplet. The uisetcolor tool can help you select a color interactively and determine its RGB triplet.
fima v
2019년 5월 10일
So given your example its.
v = 1:10;
plot(v, v.^2, 'Color', [0 1 1], 'Marker', 'pentagram')
Thank you very much.
[0 1 1] corresponds to green + blue = cyan. So if you want to plot your data in cyan yes, that will work. If you did a different combination, like [0.5 0 0] (maroon) or [0.75 0.75 0.75] (silver) it would be different colors. I got those color combinations from Wikipedia. MATLAB doesn't recognize the names 'maroon' or 'silver' but it does recognize the RGB triplet.
There are other Name / Value pairs plot recognizes, like 'LineWidth' (to make thicker or thinner lines) and 'MarkerSize' (larger or smaller markers.) The plot documentation pages lists the most commonly used one, the documentation page listing the properties of the graphics object plot returns (which is linked at the end of the plot documentation page) lists more.
v = 1:10;
plot(v, v.^2, ... % plot points on y = x.^2
'Color', [0.75 0.75 0.75], ... % in silver / light gray
'LineWidth', 4, ... % using a thick line
'Marker', 'p', ... % with star markers
'MarkerSize', 24) % and make the stars big
fima v
2019년 5월 10일
Thank you very much.
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Line Plots에 대해 자세히 알아보기
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
