MATLAB study notes (c) Advanced Drawing

Note in some images, and video codes from the B station PPT teacher Guo Yanfu

Advanced Drawing

Advanced 2D drawing (important function instruction)

  • FIG logarithm plot of the number of
  • plotyy
  • histogram chart (overall)
  • bar charts charts (individual)
  • pie charts pie charts
  • ploar chart (similar to the polar diagram)
  • stairs and stem charts
  • boxplot and error bar
  • fill color fill and text

Match colors

  • imagesc
  • colorbar
  • colormap

3D mapping function

  • plot3(x,y,z)

  • 3D surface plot:
    1 meshgrid()
    2 mash()和surf()
    3 contour()
    4 meshc() 和surfc()
    5view()
    6light()
    7patch()

1.1 pairs logarithmic plot

logspace(-1,1,100):
semilogx (x, y): x-axis the logarithm
loglog (x, y): xy axes are logarithmic
set (gca, 'XGrid', 'on'); plus mesh

x=logspace(-1,1,100);
y=x.^2;
subplot(2,2,1); plot(x,y);title(‘Plot’);
subplot(2,2,2); semilogx(x,y);title(‘Semilogx’);
subplot(2,2,3); semilogy(x,y);title(‘Semilogy’);
subplot(2,2,4); loglog(x,y);title(‘LogLog’);

Here Insert Picture Description

1.2
plotyy ()

Here Insert Picture Description

Here Insert Picture Description
1.3histogram
hist(x,n)

Here is a quote

Here Insert Picture Description
1.4

  • bar (y)
  • bar3 (y)

Here is a quote

Here Insert Picture Description

bar (y, 'stacked') ; stacked
barh (y); sideways

Here Insert Picture Description
Here Insert Picture Description

x=[1 2 5 4 8];
y=[x;1:5];
barh(y,‘stacked’);
Here Insert Picture Description

Pie chart 1.5

  • pie();

Here is a quote

Here Insert Picture Description
Here Insert Picture Description

a = [May 10 20 30];
pie3 (a, [1,1,1,1]);
Here Insert Picture Description

1.6

  • polar (theta, r); where theta is the angle, r is the radius of

Here is a quote

Here Insert Picture Description

  • stairs(y)
  • stem (s)

Here is a quote

Here Insert Picture Description
doubt?
Here Insert Picture Description

1.7

  • boxplot(x,y)
  • errorbar (x, y, e) where e is the error section

Here is a quote

Here Insert Picture Description
1.8

  • fill()

Here is a quote

Here Insert Picture Description

t=linspace(0,2*pi,5);
x=sin(t);
y=cos(t);
h=fill(x,y,‘y’);axis square off;
set(h,‘linewidth’,7);
text(0,0,‘WAIT’,‘Color’,‘k’,‘FontSize’,70,…
‘FontWeight’,‘bold’,‘HorizontalAlignment’,‘center’);

Here Insert Picture Description
2.0
[the RGB]
255 corresponding to the FF
Here Insert Picture Description
2.1

  • the imagesc () indicates color value

Here is a quote

Here Insert Picture Description
2.2

  • the colorbar () displays a color numerical value corresponding to the next article in the axis
  • colormap (Name) value corresponds to the color change
    Here Insert Picture Description

x=[1:10;3:12;5:14];
imagesc(x);
colorbar;
map=zeros(256,3);
map(:,2)=(0:255)/255;
colormap(map);

Here Insert Picture Description
3.0
Here Insert Picture Description
3.1

  • plot3(x,y,z)

Here is a quote

Here Insert Picture Description

t=0:pi/50:10*pi;
plot3(sin(t),cos(t),t);
grid on;axis square;box on

Here Insert Picture Description

turns=40pi;
t=linspace(0,turns,4000);
x=cos(t).
(turns-t)./turns;
y=sin(t).*(turns-t)./turns;
z=t./turns;
plot3(x,y,z);
grid on;

Here Insert Picture Description
3.2

  • [X,Y]=meshgrid(x,y) 使用这个函数可以得到两个有对应点的矩阵

Here is a quote

Here Insert Picture Description
3.3

  • mesh()没有小格子和surf()有小格子

Here is a quote

Here Insert Picture Description
3.4

  • contour()有点类似于投影,让3D变成2D

Here is a quote

Here Insert Picture Description
有一页看不懂
Here Insert Picture Description
3.5

  • meshc()和surfc()
  • 3D加2D

Here is a quote

Here Insert Picture Description
3.6

  • view(x,y)
  • x,y是想看的角度
  • [X,Y,Z]=sphere(30),其中参数30表示球面沿着经度、纬度方向被分成的面片数。
  • shading 设置颜色着色属性
  • shading flat 每个网格线段和面具有恒定颜色,该颜色由该线段的端点或该面的角边处具有最小索引的颜色值确定。
  • material就是让做出的表面图有质地感,包括亮度,暗度,金属感等等。
  • material SHINY makes the objects shiny.

Here is a quote

Here Insert Picture Description
3.7

  • light(‘position’,[ ])
  • shading interp by interpolating lines of each color plane or FIG index or true color values ​​to change the color of the line or plane.

Here is a quote

Here Insert Picture Description

3.8

  • patch () draw a polygon

Here is a quote

Here Insert Picture Description

Released six original articles · won praise 0 · Views 210

Guess you like

Origin blog.csdn.net/qq_45793719/article/details/104291702