Skip to content

Commit 97729fd

Browse files
zinsmattlava
authored andcommitted
Add possibility to pass additional parameters to scatter (like color or label)
1 parent 5adfbe0 commit 97729fd

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

matplotlibcpp.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,8 @@ bool hist(const std::vector<Numeric>& y, long bins=10,std::string color="b",
659659
template<typename NumericX, typename NumericY>
660660
bool scatter(const std::vector<NumericX>& x,
661661
const std::vector<NumericY>& y,
662-
const double s=1.0) // The marker size in points**2
662+
const double s=1.0, // The marker size in points**2
663+
const std::unordered_map<std::string, std::string> & keywords = {})
663664
{
664665
assert(x.size() == y.size());
665666

@@ -668,6 +669,10 @@ bool scatter(const std::vector<NumericX>& x,
668669

669670
PyObject* kwargs = PyDict_New();
670671
PyDict_SetItemString(kwargs, "s", PyLong_FromLong(s));
672+
for (const auto& it : keywords)
673+
{
674+
PyDict_SetItemString(kwargs, it.first.c_str(), PyString_FromString(it.second.c_str()));
675+
}
671676

672677
PyObject* plot_args = PyTuple_New(2);
673678
PyTuple_SetItem(plot_args, 0, xarray);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy