MATLAB 函数绘图和直线有何不同?

发布于 2024-08-25 08:16:23 字数 74 浏览 3 评论 0原文

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

What's the difference between the functions plot and line in MATLAB? Are they doing the same thing?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

温柔戏命师 2024-09-01 08:16:23

函数 plotline 做几乎相同的事情,但是 plot 是一个高级函数,可能与其他图形对象有更多的交互。可以找到高级和低级函数的简要摘要 此处。像 plot 这样的高级函数很可能在内部调用像 line 这样的原始函数来创建它们的图形,但它们也可以修改或与其父级 。来自 line

plot 函数不同,line 函数在绘图之前不会调用 newplot,并且不考虑 NextPlot 的值图形或坐标区的 属性。它只是将线添加到当前坐标区,而不删除其他图形对象或重置坐标区属性。但是,某些轴属性(例如轴限制)可以更新以适应线条。

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

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

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

如果您第二次调用 line 函数,MATLAB 将在当前坐标区中绘制第二条线,而不擦除第一条线。此行为不同于诸如 plot 之类的高级函数,后者删除图形对象并重置所有轴属性(位置单位)。您可以使用 hold< 来更改高级函数的行为/code>命令或通过更改轴的设置 NextPlot 属性。

plotline 函数也会以不同的方式影响自动线条着色,如此处< /a>.

The functions plot and line do nearly the same thing, but plot is a high-level function that may have more interaction with other graphics objects. A brief summary of high-level and low-level functions can be found here. High-level functions like plot are likely internally calling primitive functions like line to create their graphics, but they can also modify or interact with properties of their parent axes or figure. From the documentation for 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.

For example, if you call the line function:

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

MATLAB draws a red line in the current axes using the specified data values. If there is no axes, MATLAB creates one. If there is no figure window in which to create the axes, MATLAB creates it as well.

If you call the line function a second time, MATLAB draws the second line in the current axes without erasing the first line. This behavior is different from high-level functions like plot that delete graphics objects and reset all axes properties (except Position and Units). You can change the behavior of high-level functions by using the hold command or by changing the setting of the axes NextPlot property.

The plot and line functions also differently affect automatic line coloring, as show here.

夏日浅笑〃 2024-09-01 08:16:23

plot() 用于创建图形,通常是某种折线图。 line() 创建一个 lin 对象,该对象可能出现在图形中。不,他们没有做同样的事情。我通常使用 plot 创建图形,使用 line 向现有图形添加线条。

如果这不能回答您的问题,请查看详细介绍这些问题的文档。

plot() is used to create a graphic, usually a line graph of some sort. line() creates a lin object which may appear in, say, a graphic. No they're not doing the same thing. I'd usually use plot for creating a graphic, line for adding lines to an existing graphic.

If this doesn't answer your question, have a look at the documentation which covers these matters in great detail.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文