栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

matplotcpp使用

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

matplotcpp使用

介绍:
  • matplotlib-cpp:C++ ploting library
简单使用: 1. minimal example:
#include "matplotlibcpp.h"
namespace plt = matplotlibcpp;
int main()
{
	plt::plot({1,3,2,4});
	plt::show();
}
2. g++ 编译
g++ minimal.cpp -I/usr/include/pyhon3.8 -lpython3.8
3. cmake
target_include_directories(${PROJECT_NAME} PRIVATE ${Python3_INCLUDE_DIRS} ${Python3_NumPy_INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME} INTERFACE
        Python3::Module
        Python3::NumPy
        )
target_link_libraries(${PROJECT_NAME} PRIVATE ${Python3_LIBRARIES})
问题:
  • warning: /python3/dist-packages/gi/module.py:171: Warning:g_once_init_leave: assertion ‘result != 0’ failed
解决:
  • the matplotlib backend that use gtk+3 while cv2.show() use gtk2.x to process
  • 只使用matplot可视化,不使用imshow
The Docs 1. plot y versus x.
#include 
#include "matplotlibcpp.h"
namespace plt = matplotlibcpp;

int main() {
  std::vector x = {1, 2, 3, 4};
  std::vector y = {1, 4, 9, 16};

  plt::plot(x, y);
  plt::show();

  return 0;
}

g++ test1.cpp -std=c++11 -I/usr/include/python3.8 -I/home/xx/.local/lib/python3.8/site-packages/numpy/core/include -lpython3.8

2. 多个函数 3. the style of a line 4.
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/1025659.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号