diff --git a/Makefile.Python3 b/Makefile.Python3 new file mode 100644 index 0000000..003b6d2 --- /dev/null +++ b/Makefile.Python3 @@ -0,0 +1,45 @@ +examples: minimal basic modern animation nonblock xkcd quiver bar surface fill_inbetween fill update imshow + +CPPFLAGS = -g -O0 -DSF_VISIBILITY -fvisibility=hidden -fno-strict-aliasing -Wall + +minimal: examples/minimal.cpp matplotlibcpp.h + cd examples && g++ $(CPPFLAGS) -DWITHOUT_NUMPY minimal.cpp -Iext/plot/ $(shell python3-config --includes) $(shell python3-config --ldflags) -lopencv_core -lopencv_imgproc -o minimal -std=c++17 + +basic: examples/basic.cpp matplotlibcpp.h + cd examples && g++ $(CPPFLAGS) basic.cpp -Iext/plot/ $(shell python3-config --includes) $(shell python3-config --ldflags) -lopencv_core -lopencv_imgproc -o basic -std=c++17 + +modern: examples/modern.cpp matplotlibcpp.h + cd examples && g++ $(CPPFLAGS) modern.cpp -Iext/plot/ $(shell python3-config --includes) $(shell python3-config --ldflags) -lopencv_core -lopencv_imgproc -o modern -std=c++17 + +animation: examples/animation.cpp matplotlibcpp.h + cd examples && g++ $(CPPFLAGS) animation.cpp -Iext/plot/ $(shell python3-config --includes) $(shell python3-config --ldflags) -lopencv_core -lopencv_imgproc -o animation -std=c++17 + +nonblock: examples/nonblock.cpp matplotlibcpp.h + cd examples && g++ $(CPPFLAGS) nonblock.cpp -Iext/plot/ $(shell python3-config --includes) $(shell python3-config --ldflags) -lopencv_core -lopencv_imgproc -o nonblock -std=c++17 + +quiver: examples/quiver.cpp matplotlibcpp.h + cd examples && g++ $(CPPFLAGS) quiver.cpp -Iext/plot/ $(shell python3-config --includes) $(shell python3-config --ldflags) -lopencv_core -lopencv_imgproc -o quiver -std=c++17 + +xkcd: examples/xkcd.cpp matplotlibcpp.h + cd examples && g++ $(CPPFLAGS) xkcd.cpp -Iext/plot/ $(shell python3-config --includes) $(shell python3-config --ldflags) -lopencv_core -lopencv_imgproc -o xkcd -std=c++17 + +bar: examples/bar.cpp matplotlibcpp.h + cd examples && g++ $(CPPFLAGS) bar.cpp -Iext/plot/ $(shell python3-config --includes) $(shell python3-config --ldflags) -lopencv_core -lopencv_imgproc -o bar -std=c++17 + +surface: examples/surface.cpp matplotlibcpp.h + cd examples && g++ $(CPPFLAGS) surface.cpp -Iext/plot/ $(shell python3-config --includes) $(shell python3-config --ldflags) -lopencv_core -lopencv_imgproc -o surface -std=c++17 + +fill_inbetween: examples/fill_inbetween.cpp matplotlibcpp.h + cd examples && g++ $(CPPFLAGS) fill_inbetween.cpp -Iext/plot/ $(shell python3-config --includes) $(shell python3-config --ldflags) -lopencv_core -lopencv_imgproc -o fill_inbetween -std=c++17 + +fill: examples/fill.cpp matplotlibcpp.h + cd examples && g++ $(CPPFLAGS) fill.cpp -Iext/plot/ $(shell python3-config --includes) $(shell python3-config --ldflags) -lopencv_core -lopencv_imgproc -o fill -std=c++17 + +update: examples/update.cpp matplotlibcpp.h + cd examples && g++ update.cpp $(CPPFLAGS) -Iext/plot/ $(shell python3-config --includes) $(shell python3-config --ldflags) -lopencv_core -lopencv_imgproc -o update -std=c++1z + +imshow: examples/imshow.cpp matplotlibcpp.h + cd examples && g++ $(CPPFLAGS) imshow.cpp -Iext/plot/ $(shell python3-config --includes) $(shell python3-config --ldflags) -lopencv_core -lopencv_imgproc -o imshow -std=c++17 + +clean: + rm -f examples/{minimal,basic,modern,animation,nonblock,xkcd,quiver,bar,surface,fill_inbetween,fill,update,imshow} diff --git a/examples/basic.cpp b/examples/basic.cpp index 2dc34c7..ac7b827 100644 --- a/examples/basic.cpp +++ b/examples/basic.cpp @@ -7,6 +7,7 @@ namespace plt = matplotlibcpp; int main() { + plt::detail::_interpreter::get(); // Prepare data. int n = 5000; std::vector x(n), y(n), z(n), w(n,2); diff --git a/examples/imshow.cpp b/examples/imshow.cpp index b11661e..578b5f6 100644 --- a/examples/imshow.cpp +++ b/examples/imshow.cpp @@ -8,6 +8,7 @@ namespace plt = matplotlibcpp; int main() { + plt::detail::_interpreter::get(); // Prepare data int ncols = 500, nrows = 300; std::vector z(ncols * nrows); diff --git a/examples/minimal.cpp b/examples/minimal.cpp index fbe1e1c..91159c2 100644 --- a/examples/minimal.cpp +++ b/examples/minimal.cpp @@ -3,6 +3,7 @@ namespace plt = matplotlibcpp; int main() { + plt::detail::_interpreter::get(); plt::plot({1,3,2,4}); plt::show(); } diff --git a/examples/modern.cpp b/examples/modern.cpp index a8aa0c7..e764d7e 100644 --- a/examples/modern.cpp +++ b/examples/modern.cpp @@ -7,6 +7,7 @@ namespace plt = matplotlibcpp; int main() { + plt::detail::_interpreter::get(); // plot(y) - the x-coordinates are implicitly set to [0,1,...,n) //plt::plot({1,2,3,4}); diff --git a/examples/nonblock.cpp b/examples/nonblock.cpp index 327d96c..1d2cc59 100644 --- a/examples/nonblock.cpp +++ b/examples/nonblock.cpp @@ -10,6 +10,7 @@ using namespace std; int main() { + plt::detail::_interpreter::get(); // Prepare data. int n = 5000; std::vector x(n), y(n), z(n), w(n,2); diff --git a/examples/update.cpp b/examples/update.cpp index 64f4906..4007eb8 100644 --- a/examples/update.cpp +++ b/examples/update.cpp @@ -20,6 +20,7 @@ void update_window(const double x, const double y, const double t, int main() { + plt::detail::_interpreter::get(); size_t n = 1000; std::vector x, y; diff --git a/matplotlibcpp.h b/matplotlibcpp.h index 6a428d4..8cdd7d1 100644 --- a/matplotlibcpp.h +++ b/matplotlibcpp.h @@ -1701,7 +1701,7 @@ struct plot_impl PyObject* pystring = PyString_FromString(format.c_str()); auto itx = begin(x), ity = begin(y); - for(size_t i = 0; i < xs; ++i) { + for(auto i = 0; i < xs; ++i) { PyList_SetItem(xlist, i, PyFloat_FromDouble(*itx++)); PyList_SetItem(ylist, i, PyFloat_FromDouble(*ity++)); }