Skip to content
Snippets Groups Projects
Commit bcebcfaa authored by soblin's avatar soblin
Browse files

added cla_pause

parent d745d41d
No related branches found
No related tags found
No related merge requests found
...@@ -29,6 +29,7 @@ if(${ADD_DEMO}) ...@@ -29,6 +29,7 @@ if(${ADD_DEMO})
add_subdirectory(gallery/statistics) add_subdirectory(gallery/statistics)
add_subdirectory(gallery/images_contours_and_fields) add_subdirectory(gallery/images_contours_and_fields)
add_subdirectory(gallery/shapes_and_collections) add_subdirectory(gallery/shapes_and_collections)
add_subdirectory(gallery/artist_animation)
endif() endif()
if(NOT DEFINED DO_TEST) if(NOT DEFINED DO_TEST)
... ...
......
add_demo(cla_pause cla_pause.cpp)
add_custom_target(artist_animation
DEPENDS cla_pause
COMMAND cla_pause
COMMENT "running artist_animation"
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../images"
)
#include <pybind11/embed.h>
#include <pybind11/stl.h>
#include <matplotlibcpp17/matplotlibcpp17.h>
#include <vector>
#include <algorithm>
#include <string>
namespace py = pybind11;
using namespace py::literals;
using namespace std;
using namespace matplotlibcpp17::util;
int main() {
py::scoped_interpreter guard{};
auto plt = matplotlibcpp17::pyplot::import();
vector<int> data;
const int N = 10;
for (int i = 0; i <= N; ++i) {
plt.xlim(0, 10);
plt.ylim(0, 10);
data.push_back(i);
plt.plot(data);
plt.pause(1);
plt.cla();
}
return 0;
}
...@@ -9,11 +9,13 @@ struct DECL_STRUCT_ATTR PyPlot { ...@@ -9,11 +9,13 @@ struct DECL_STRUCT_ATTR PyPlot {
void load_attrs() { void load_attrs() {
LOAD_NONVOID_ATTR(axes, mod); LOAD_NONVOID_ATTR(axes, mod);
LOAD_VOID_ATTR(axis, mod); LOAD_VOID_ATTR(axis, mod);
LOAD_VOID_ATTR(cla, mod);
LOAD_VOID_ATTR(clf, mod); LOAD_VOID_ATTR(clf, mod);
LOAD_NONVOID_ATTR(figure, mod); LOAD_NONVOID_ATTR(figure, mod);
LOAD_NONVOID_ATTR(gca, mod); LOAD_NONVOID_ATTR(gca, mod);
LOAD_NONVOID_ATTR(gcf, mod); LOAD_NONVOID_ATTR(gcf, mod);
LOAD_VOID_ATTR(legend, mod); LOAD_VOID_ATTR(legend, mod);
LOAD_VOID_ATTR(pause, mod);
LOAD_VOID_ATTR(plot, mod); LOAD_VOID_ATTR(plot, mod);
LOAD_VOID_ATTR(quiver, mod); LOAD_VOID_ATTR(quiver, mod);
LOAD_VOID_ATTR(savefig, mod); LOAD_VOID_ATTR(savefig, mod);
...@@ -22,7 +24,9 @@ struct DECL_STRUCT_ATTR PyPlot { ...@@ -22,7 +24,9 @@ struct DECL_STRUCT_ATTR PyPlot {
LOAD_NONVOID_ATTR(subplot, mod); LOAD_NONVOID_ATTR(subplot, mod);
LOAD_NONVOID_ATTR(subplots, mod); LOAD_NONVOID_ATTR(subplots, mod);
LOAD_VOID_ATTR(xlabel, mod); LOAD_VOID_ATTR(xlabel, mod);
LOAD_VOID_ATTR(xlim, mod);
LOAD_VOID_ATTR(ylabel, mod); LOAD_VOID_ATTR(ylabel, mod);
LOAD_VOID_ATTR(ylim, mod);
} }
pybind11::module mod; pybind11::module mod;
...@@ -33,6 +37,9 @@ struct DECL_STRUCT_ATTR PyPlot { ...@@ -33,6 +37,9 @@ struct DECL_STRUCT_ATTR PyPlot {
// axis // axis
pybind11::object axis; pybind11::object axis;
// cla
pybind11::object cla;
// clf // clf
pybind11::object clf; pybind11::object clf;
...@@ -52,6 +59,9 @@ struct DECL_STRUCT_ATTR PyPlot { ...@@ -52,6 +59,9 @@ struct DECL_STRUCT_ATTR PyPlot {
// legend // legend
pybind11::object legend; pybind11::object legend;
// pause
pybind11::object pause;
// plot // plot
// TODO: should return `artists` for gif? // TODO: should return `artists` for gif?
pybind11::object plot; pybind11::object plot;
...@@ -82,8 +92,14 @@ struct DECL_STRUCT_ATTR PyPlot { ...@@ -82,8 +92,14 @@ struct DECL_STRUCT_ATTR PyPlot {
// xlabel // xlabel
pybind11::object xlabel; pybind11::object xlabel;
// xlim
pybind11::object xlim;
// ylabel // ylabel
pybind11::object ylabel; pybind11::object ylabel;
// ylim
pybind11::object ylim;
}; };
// axes // axes
... ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment