diff --git a/CMakeLists.txt b/CMakeLists.txt index bb2decd8..6ef49b96 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -81,6 +81,10 @@ add_executable(subplot2grid examples/subplot2grid.cpp) target_link_libraries(subplot2grid PRIVATE matplotlib_cpp) set_target_properties(subplot2grid PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") +add_executable(subplot examples/subplot.cpp) +target_link_libraries(subplot PRIVATE matplotlib_cpp) +set_target_properties(subplot PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") + add_executable(lines3d examples/lines3d.cpp) target_link_libraries(lines3d PRIVATE matplotlib_cpp) set_target_properties(lines3d PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin") diff --git a/examples/basic.cpp b/examples/basic.cpp index 2dc34c74..dbe41110 100644 --- a/examples/basic.cpp +++ b/examples/basic.cpp @@ -1,6 +1,8 @@ #define _USE_MATH_DEFINES #include #include +#include +#include #include "../matplotlibcpp.h" namespace plt = matplotlibcpp; @@ -41,4 +43,9 @@ int main() const char* filename = "./basic.png"; std::cout << "Saving result to " << filename << std::endl;; plt::save(filename); + plt::show(false); + while (true) { + sleep(1); + printf("got one\r\n"); + } } diff --git a/matplotlibcpp.h b/matplotlibcpp.h index d95d46ad..aa85bc55 100644 --- a/matplotlibcpp.h +++ b/matplotlibcpp.h @@ -2255,9 +2255,9 @@ inline void subplot(long nrows, long ncols, long plot_number) // construct positional args PyObject* args = PyTuple_New(3); - 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, PyInt_FromLong(nrows)); + PyTuple_SetItem(args, 1, PyInt_FromLong(ncols)); + PyTuple_SetItem(args, 2, PyInt_FromLong(plot_number)); PyObject* res = PyObject_CallObject(detail::_interpreter::get().s_python_function_subplot, args); if(!res) throw std::runtime_error("Call to subplot() failed.");