From b93e2292d5c3af19e8440df5668a0c2d221c0936 Mon Sep 17 00:00:00 2001 From: Matthieu Zins Date: Sun, 24 Nov 2019 22:06:49 +0100 Subject: [PATCH 1/2] Add possibility to pass additional parameters to scatter (like color or label) --- matplotlibcpp.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/matplotlibcpp.h b/matplotlibcpp.h index 82dbc6b6..ac289378 100644 --- a/matplotlibcpp.h +++ b/matplotlibcpp.h @@ -659,7 +659,8 @@ bool hist(const std::vector& y, long bins=10,std::string color="b", template bool scatter(const std::vector& x, const std::vector& y, - const double s=1.0) // The marker size in points**2 + const double s=1.0, // The marker size in points**2 + const std::unordered_map & keywords = {}) { assert(x.size() == y.size()); @@ -668,6 +669,10 @@ bool scatter(const std::vector& x, PyObject* kwargs = PyDict_New(); PyDict_SetItemString(kwargs, "s", PyLong_FromLong(s)); + for (const auto& it : keywords) + { + PyDict_SetItemString(kwargs, it.first.c_str(), PyString_FromString(it.second.c_str())); + } PyObject* plot_args = PyTuple_New(2); PyTuple_SetItem(plot_args, 0, xarray); From 4d831c61d2a525c340d44e6a7fed7288c18e17f4 Mon Sep 17 00:00:00 2001 From: Matthieu Zins Date: Wed, 27 Nov 2019 07:09:27 +0100 Subject: [PATCH 2/2] Fix multiple definition of subplot2grid --- matplotlibcpp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/matplotlibcpp.h b/matplotlibcpp.h index ac289378..8ae5b84e 100644 --- a/matplotlibcpp.h +++ b/matplotlibcpp.h @@ -1390,7 +1390,7 @@ inline void subplot(long nrows, long ncols, long plot_number) Py_DECREF(res); } -void subplot2grid(long nrows, long ncols, long rowid=0, long colid=0, long rowspan=1, long colspan=1) +inline void subplot2grid(long nrows, long ncols, long rowid=0, long colid=0, long rowspan=1, long colspan=1) { PyObject* shape = PyTuple_New(2); PyTuple_SetItem(shape, 0, PyLong_FromLong(nrows));