contourf matplotlib中的levels参数是什么意思?

2024-10-05 10:53:00 发布

您现在位置:Python中文网/ 问答频道 /正文

这个问题是关于matploblib函数的。 (https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.axes.Axes.contourf.html

函数的文档将levels参数描述为

levels : int or array-like, optional

If array-like, draw contour lines at the specified levels. The values must be in increasing order.

我的问题是这些水平的轮廓意味着什么?它们是指x-y平面上点的密度吗


Tags: 函数httpsorgapimatplotlibhtmlasarray
1条回答
网友
1楼 · 发布于 2024-10-05 10:53:00

Wikipedia

A contour line (also isoline, isopleth, or isarithm) of a function of two variables is a curve along which the function has a constant value, so that the curve joins points of equal value.

所以如果你有一个函数f(x,y),那么在a层次上的轮廓就是一条穿过f(x,y) == a点的线。您可以提供多个级别a1, a2, a3, ...来获得多条等高线,一个位于f(x,y) == a1,一个位于f(x,y) == a2,等等

在matplotlib语法中

plt.contour(x, y, f(x,y), levels=[a1, a2, a3])

相关问题 更多 >

    热门问题