Skip to content

Commit b79ca6d

Browse files
takolocolava
authored andcommitted
feat: Add keyword argument support to legend()
1 parent 374dcd0 commit b79ca6d

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

matplotlibcpp.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1565,6 +1565,24 @@ inline void legend()
15651565
Py_DECREF(res);
15661566
}
15671567

1568+
inline void legend(const std::map<std::string, std::string>& keywords)
1569+
{
1570+
detail::_interpreter::get();
1571+
1572+
// construct keyword args
1573+
PyObject* kwargs = PyDict_New();
1574+
for(std::map<std::string, std::string>::const_iterator it = keywords.begin(); it != keywords.end(); ++it)
1575+
{
1576+
PyDict_SetItemString(kwargs, it->first.c_str(), PyString_FromString(it->second.c_str()));
1577+
}
1578+
1579+
PyObject* res = PyObject_Call(detail::_interpreter::get().s_python_function_legend, detail::_interpreter::get().s_python_empty_tuple, kwargs);
1580+
if(!res) throw std::runtime_error("Call to legend() failed.");
1581+
1582+
Py_DECREF(kwargs);
1583+
Py_DECREF(res);
1584+
}
1585+
15681586
template<typename Numeric>
15691587
void ylim(Numeric left, Numeric right)
15701588
{

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