c++使用matplotlibcpp,subplot() 报错问题-ubuntu22.04

使用 matplotlibcpp.h 在 C++ 代码中绘制图形plt::subplot();程序抛出运行时错误,

terminate called after throwing an instance of 'std::runtime_error'
what(): Call to subplot() failed.

解决方法:

在matplotlibcpp.h文件中把

PyTuple_SetItem(args, 0, PyFloat_FromDouble(nrows));
PyTuple_SetItem(args, 1, PyFloat_FromDouble(ncols));
PyTuple_SetItem(args, 2, PyFloat_FromDouble(plot_number));

替换成

PyTuple_SetItem(args, 0, PyLong_FromDouble(nrows));
PyTuple_SetItem(args, 1, PyLong_FromDouble(ncols));
PyTuple_SetItem(args, 2, PyLong_FromDouble(plot_number));

已测试过。

posted on 2024-07-01 16:06  gary_123  阅读(20)  评论(0编辑  收藏  举报

导航