1、matplotlibcpp
matplotlibcpp包,是一个利用C++实现的调用Python接口和Matplotlib实现绘图的工具包。github网址。
2、环境
配置python需要的环境
sudo apt-get install python3-dev
3、使用
在CmakeList.txt
中添加
find_package(PythonLibs REQUIRED)
include_directories(
${PYTHON_INCLUDE_DIRS}
)
target_link_libraries(${PROJ_NAME}
${PYTHON_LIBRARIES}
)
并且将matplotlibcpp.h 文件添加到头文件目录即可。
4、例子
4.1 例子1
#include "matplotlibcpp.h"
#include <cmath>
namespace plt = matplotlibcpp;
int main()
{
// Prepare data.
int n = 5000;
std::vector<double> x(n), y(n), z(n), w(n,2);
for