开发者

windows下vscode环境c++利用matplotlibcpp绘图

目录
  • 1. 下载matplotlibcpp
  • 2. matplotlibcpp测试代码
  • 3. 配置.vscode
    • 3.1 配置tasks.json
    • 3.2 配置c_cpp_properties.json
  • 4. 注释掉matplotlibcpp.h中两行代码
    • 5. 运行

      1. 下载matplotlibcpp

      https://github.com/lava/matplotlib-cp开发者_Go学习p

      2. matplotlibcpp测试代码

      #include "matplotlibcpp.h"
      namespace plt = matplotlibcpp;
      int main() {
          plt::plot({1,3,2,4});
          plt::show();
      }

      3. 配置.vscode

      3.1 配置tasks.json

      在args里面添加如下路径,根据自己的实际路径进行配置。

      // matplotlibcpp
      "-I", "F:\\c++_libraries\\matplotlibcpp",  // matplotlibcpp.h路径
      "-I", "F:\\python3.7.8\\include",  // Python.h路径
      "-I", "F:\php\python3.7.8\\http://www.devze.comLib\\site-packages\\numpy\\core\\include",  // numpy/arrayobject.h路径
      "-L", "F:\\python3.7.8",  // python37.dll的所在目录
      "-l", "python37"  // python37.dll动态库

      3.2 配置c_cpp_properties.json

      在includePath中添加如下路径,根据自己的实际路径进行配置。

      // matplotlibcpp
      "F:\\c++_libraries\\matplotlibcpp",  // matplotlibcpp.h路径
      "F:\\python3.7.8\\include",  // Python.h路径
      "F:\\python3.7.8\javascriptLib\\site-packages\\numpy\\core\\include"  // numpy/arrayobject.h路径

      4. 注释掉matplotlibcpp.h中两行代码

      配置完以后,如果直接运行,会报错matplotlibcpp.h中有两行重复定义,注释即可。官方代码也给出了提示。

      // Sanity checks; comment them out or change tpythonhe numpy type below if you're compiling on
      // a platform where they don't apply
      static_assert(sizeof(long long) == 8);
      // template <> struct select_npy_type<long long> { const static NPY_TYPES type = NPY_INT64; };
      static_assert(sizeof(unsigned long long) == 8);
      // template <> struct select_npy_type<unsigned long long> { const static NPY_TYPES type = NPY_UINT64; };

      5. 运行

      最后运行即可,得到如下效果。

      windows下vscode环境c++利用matplotlibcpp绘图

      到此这篇关于Windows下vscode环境c++利用matplotli编程客栈bcpp绘图的文章就介绍到这了,更多相关vscode环境c++ matplotlibcpp绘图内容请搜索我们以前的文章或继续浏览下面的相关文章希望大家以后多多支持我们! 

      0

      上一篇:

      下一篇:

      精彩评论

      暂无评论...
      验证码 换一张
      取 消

      最新开发

      开发排行榜