matlab - MATLAB 函数 plot 和 line 有何不同?

标签 matlab plot line

MATLAB 中的函数plotline 有什么区别?他们在做同样的事情吗?

最佳答案

函数 plotline 做几乎相同的事情,但 plot 是一个高级函数,可能与其他图形对象有更多交互。可以在 here 中找到高级和低级函数的简要总结。像 plot 这样的高级函数可能会在内部调用像 line 这样的原始函数来创建它们的图形,但它们也可以修改它们的父 axesfigure 的属性或与之交互。来自 line 的文档:

Unlike the plot function, the line function does not call newplot before plotting and does not respect the value of the NextPlot property for the figure or axes. It simply adds the line to the current axes without deleting other graphics objects or resetting axes properties. However, some axes properties, such as the axis limits, can update to accommodate the line.

例如,如果您调用 line 函数:

line('XData', x, 'YData', y, 'ZData', z, 'Color', 'r');

MATLAB 使用指定的数据值在当前坐标区中绘制一条红线。如果没有轴,MATLAB 会创建一个。如果没有可在其中创建坐标区的图窗窗口,MATLAB 也会创建它。

如果您第二次调用 line 函数,MATLAB 会在当前坐标区中绘制第二条线,而不会删除第一条线。此行为不同于 plot 等删除图形对象并重置所有轴属性(PositionUnits 除外)的高级函数。您可以使用 hold 命令或更改轴 NextPlot 属性的设置来更改高级函数的行为。

plotline 函数对自动线条着色的影响也不同,如 here 所示。

关于matlab - MATLAB 函数 plot 和 line 有何不同?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2447127/

相关文章:

matlab - 如何删除在 MATLAB 命令行中输入的字符

matlab - 如何裁剪图像中的多个对象 [MATLAB]

matlab - 将一组 (X, Y, Z) 点绘制为一个漂亮的封闭对象?

r - 如何使用灰度按原样在 R 中绘制矩阵?

使用 ggplot2 reshape 数据以在 R 中绘制

bash - 在 nohup bash 脚本中运行多个 matlab 实例

r - 增加情节刻度线的长度

d3.js - 在 D3.js 中绘制多条线

java - 如何填充行与行之间的空格?

SQL:如何将一替换为二?