c++ - 如何使用visual studio c++绘制图表

标签 c++ visual-studio graph

我想使用带有 C++ 代码的 Visual Studio 创建图表。图表应基于两个轴。 “x”轴显示时间,“y”轴显示数组数据。数组数据有 100 个元素和一个数据在一秒钟内读取。如何使用任何其他图形库实现代码?

最佳答案

1) 结帐并将 Microsoft vcpkg 安装到新文件夹(请参阅此处的 1 步说明:https://github.com/Microsoft/vcpkg)

2) vcpkg.exe 从 vcpkg 文件夹安装 plplot

3) vcpkg.exe 集成项目 将指导您将 plplot 添加到您的 MSVC 项目

4) 将此指令粘贴到 Nuget 控制台:

enter image description here

5) 粘贴并重新加载项目后,您可以尝试以下代码:

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <cmath>
#include "plplot\plstream.h"
using namespace std;
const int NSIZE = 101;
int main(int argc, char ** argv) {
    PLFLT x[NSIZE], y[NSIZE];
    PLFLT xmin = 0., xmax = 1., ymin = 0., ymax = 100.;
    int   i;
    for (i = 0; i < NSIZE; i++) {
        x[i] = (PLFLT)(i) / (PLFLT)(NSIZE - 1);
        y[i] = ymax * x[i] * x[i];
    }
    auto pls = new plstream();
    plsdev("wingcc");
    pls->init();
    pls->env(xmin, xmax, ymin, ymax, 0, 0);
    pls->lab("x", "y=100 x#u2#d", "Simple PLplot demo of a 2D line plot");
    pls->line(NSIZE, x, y);
    delete pls;
}

你得到:

enter image description here

在 MSVC2015 上测试

关于c++ - 如何使用visual studio c++绘制图表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44448010/

相关文章:

c++ - 在不使用宏的情况下评估采用函数参数 DRY 的元函数?

visual-studio - 无法打开源文件 "opencv2/face.hpp"

visual-studio - 为什么 Visual Studio 2013 对 lc.exe 使用错误的 SdkToolsPath?

visual-studio - TFS查询以显示特定用户昨天更改的项目

python - 使用过去运行的预训练节点 - Pytorch Biggraph

java - HackerRank 上的道路和图书馆超时

c - 图邻接表实现(C)

c++ - 如何为 QListView 中列表项的边框设置动画?

c++ - 一直提示 "code will never be executed"

c++ - 析构函数和指向类属性的指针