我正在尝试在GNUPlotC++库中绘制一个计数,但我希望能够绘制数据中的空洞(在没有数据的情况下无需插值)。我使用的是Visual Studio 2022中的C++14。
我有以下示例代码:
#include <iostream>
#include <string>
#include <vector>
#include "gnuplot-iostream.h"
int main()
{
    vector<vector<float>> data = {};
    for (float x = -5; x <= 5; x += 0.1)
    {
        for (float y = -5; y <= 5; y += 0.1)
        {
            float dist = sqrt(pow(x, 2) + pow(y, 2));
            float z = 1 / dist;
            if ((dist > 0.1) && (z < 0.45))
                data.push_back(vector<float>{x, y, z});
        }
    }
    cout << data.size();
    Gnuplot gp;
    gp << "set title 'test'\n";
    gp << "set dgrid3d 100,100\n";
    gp << "splot" << gp.file1d(data) << "with pm3d title 'test'" << endl;
    cin.get();
    return 0;
}
生成以下等高线图:
 
然而,在上面的图中,中间的“火山口”实际上没有任何数据:
 
该函数自动插入任何没有数据的区域,以创建等高线图。
有可能以任何方式阻止轮廓函数发生这种情况吗?因此,GNUPlot轮廓函数将没有数据的区域留空,而不是插值?
目前,我正在使用dgrid3d函数创建轮廓网格,但似乎无法实现我的目标。是否有一种不同的绘图功能更适合我想要完成的任务?
感谢您阅读我的帖子,任何指导都将不胜感激。