windows下vscode環(huán)境c++利用matplotlibcpp繪圖
1. 下載matplotlibcpp
https://github.com/lava/matplotlib-cpp
2. matplotlibcpp測(cè)試代碼
#include "matplotlibcpp.h" namespace plt = matplotlibcpp; int main() { plt::plot({1,3,2,4}); plt::show(); }
3. 配置.vscode
3.1 配置tasks.json
在args里面添加如下路徑,根據(jù)自己的實(shí)際路徑進(jìn)行配置。
// matplotlibcpp "-I", "F:\\c++_libraries\\matplotlibcpp", // matplotlibcpp.h路徑 "-I", "F:\\python3.7.8\\include", // Python.h路徑 "-I", "F:\\python3.7.8\\Lib\\site-packages\\numpy\\core\\include", // numpy/arrayobject.h路徑 "-L", "F:\\python3.7.8", // python37.dll的所在目錄 "-l", "python37" // python37.dll動(dòng)態(tài)庫(kù)
3.2 配置c_cpp_properties.json
在includePath中添加如下路徑,根據(jù)自己的實(shí)際路徑進(jìn)行配置。
// matplotlibcpp "F:\\c++_libraries\\matplotlibcpp", // matplotlibcpp.h路徑 "F:\\python3.7.8\\include", // Python.h路徑 "F:\\python3.7.8\\Lib\\site-packages\\numpy\\core\\include" // numpy/arrayobject.h路徑
4. 注釋掉matplotlibcpp.h中兩行代碼
配置完以后,如果直接運(yùn)行,會(huì)報(bào)錯(cuò)matplotlibcpp.h中有兩行重復(fù)定義,注釋即可。官方代碼也給出了提示。
// Sanity checks; comment them out or change the 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. 運(yùn)行
最后運(yùn)行即可,得到如下效果。
到此這篇關(guān)于windows下vscode環(huán)境c++利用matplotlibcpp繪圖的文章就介紹到這了,更多相關(guān)vscode環(huán)境c++ matplotlibcpp繪圖內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
2~62位任意進(jìn)制轉(zhuǎn)換方法(c++)
下面小編就為大家?guī)?lái)一篇2~62位任意進(jìn)制轉(zhuǎn)換方法(c++)。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2017-06-06C++ OpenCV實(shí)現(xiàn)抖音"藍(lán)線挑戰(zhàn)"特效
這篇文章主要介紹了如何使用OpenCV C++ 實(shí)現(xiàn)抖音上的特效“藍(lán)線挑戰(zhàn)”。文中的示例代碼講解詳細(xì),對(duì)我們學(xué)習(xí)OpenCV有一定的幫助,需要的可以參考一下2022-01-01android studio創(chuàng)建C++項(xiàng)目的實(shí)現(xiàn)示例
本文主要介紹了android studio創(chuàng)建C++項(xiàng)目的實(shí)現(xiàn)示例,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2022-06-06c語(yǔ)言可變參數(shù)實(shí)現(xiàn)示例
這篇文章主要介紹了c語(yǔ)言可變參數(shù)實(shí)現(xiàn)示例,需要的朋友可以參考下2014-04-04C語(yǔ)言實(shí)現(xiàn)銀行管理系統(tǒng)(文件操作)
這篇文章主要為大家詳細(xì)介紹了C語(yǔ)言實(shí)現(xiàn)銀行管理系統(tǒng),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-03-03