绘图基础

Plot from “Data”

• MATLAB does not understand functions
  𝑓(𝑡) = sin(2𝜋𝑡)
• Strategies

  1. Generate the numeric values of a function over a specific range.
  2. Display the data “points” in a graphical way.

plot()

• plot(x,y) plots each vector pairs (x,y)
• plot(y) plots each vector pairs (x,y),where x=[1…n], n=length(y)
• Example:
  plot(cos(0:pi/20:2*pi));

hold on/off

• Use hold on to have both plots in one figure.

在一张图片上绘制两个图

Plot Style

• plot(x,y,'str') plots each vector pairs (x,y) using the format defined in str (check linespec)

绘图风格

legend()

• Add legend to graph
  legend('L1',...)
• Position adjustment

带label的函数图形

label的实现语法

title() and label()

• title()
• xlabel()
• ylabel()
• zlabel()

屏幕截图(69).png

x,y轴的名称及图片标题

text() and annotation()

• Text with mathematical expression using LaTex


Exercise

• Plot 𝑓 as a black line and 𝑔 as a series of red circles for the range t = 1 to 2 in one figure
  𝑓 = 𝑡^2 and 𝑔 = sin(2𝜋𝑡)
• Label each axis, and add title and legend

Figure Adjustment

• Several properties:

• Font
• Font size
• Line width
• Axis limit
• Tick position
• Tick label

Graphical Objects

• A figure is composed of many objects

屏幕截图(81).png

Figure Properties
屏幕截图(82).png

Modifying Properties of An Object

• Strategy:

  1. Identify the “handle” of an object
  2. Fetch or modify the object’s properties

• For example, to change the limits of the x-axis:

  1. Find the handle of the x-axis
  2. Modify the limits

1. Identifying the Handle of An Object

• Upon creation:
  h = plot(x,y);

• Utility functions:

Fetching or Modifying Properties

• To fetch properties, use
  get( )
• To modify properties, use
  set( )

Getting Object Properties

• Getting properties of a graphical object: get( )

Setting Axes Limits

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 7,504评论 0 10
  • 喜欢你就是刚注册的微博,因为想你从2015年到今天这么久,发的一直都是想你的文字。 喜欢你就是我注册的QQ小号,随...
    清清_1b6e阅读 134评论 0 0
  • 相遇在青春年少的花季雨季,是最美好的邂逅,可是,有时觉得这相遇太美好,因为后来,在眼泪中全明白一旦错过就不在…… ...
    啊栋阅读 392评论 0 0
  • 我是对咖啡反应比较敏感的人,所以一般傍晚不喝因为怕睡不着,早上或中午必喝因为精神百倍、做事效率高。今天鬼使神差在下...
    麦地水孩子阅读 534评论 0 2