Matlab's plot ~ various colors and line shapes

Plot is a commonly used command in matlab~

You can query related commands about plot drawing through help plot

[c#]  view plain copy  
  1. help plot  

wKiom1ZbCa2SAY0KAABsO3QLY8M595.png

It is recommended that you draw and test it yourself~

And these commands can be used superimposed. which is

[c#]  view plain copy  
  1. plot(x,y, 'bo' );  

A blue circle shape graph can be drawn.


In addition to the 8 colors that come with matlab, if you need to draw lines with richer colors, you can use the 'color' parameter to customize the line color. You can refer to this blog article.

http://www.cnblogs.com/takeaction/p/3789871.html


So the question is, if I use the 'color' parameter to formulate RGB colors, I can only get solid lines. If I want to use custom colors to achieve different line types, that is, the combination of RGB and line types, how to achieve it?


At the beginning, I compared the previous method, in (note that the rgb value of color in matlab is 0 to 1, corresponding to the standard RGB image value 0-255, which needs to be divided by 255)

[c#]  view plain copy  
  1. plot(x,y, 'coloro' ,[0 1 0]);  

or

[c#]  view plain copy  
  1. plot(x,y,'color',[0 1 0],'o');  

failed to achieve the purpose

Later found that putting the line type parameter before 'color' can achieve my purpose, i.e.

[c#]  view plain copy  
  1. plot(x,y,'o','color',[0 1 0]);  

In this way, you will find that your matlab can achieve various colors!


Below ~ draw a CD on the reverse side.

[c#]  view plain copy  
  1. qpskConstellation = [-1+1i 1+1i; -1-1i 1-1i]/sqrt(2);  
  2. qpsk = reshape(qpskConstellation,1,[]);   
  3. Num = 40;  
  4. outter = 60;  
  5.  for nn = 1:outter  
  6.   qpsk = qpsk * (outter-1)/outter;  
  7.   c = rand(Num,3); % 12 colors are randomly generated. RGB random.  
  8.      for idx = 1:Num  
  9.          theta = pi/2/Num*idx;  
  10.          rou = [cos(theta) sin(theta);sin(theta) -cos(theta)];  
  11.      realPart = real(qpsk);  
  12.      imagPart = imag(qpsk);  
  13.      reim = rou * [realPart;imagPart];  
  14.      realPart2 = real(qpsk*0.3);  
  15.      imagPart2 = imag(qpsk*0.3);  
  16.      reim2 = rou * [realPart2;imagPart2];   
  17.      plot(reim(1,:),reim(2,:),'o','color',c(idx,:));  
  18.      hold on;  
  19.      plot(reim2(1,:),reim2(2,:),'.','color',c(idx,:));  
  20.      hold on;  
  21.      pause(0.005);  
  22.      end  
  23.  end  

Copy and run. hehe~

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325666863&siteId=291194637