File tree Expand file tree Collapse file tree 1 file changed +16
-3
lines changed
Expand file tree Collapse file tree 1 file changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -1161,12 +1161,25 @@ inline void figure_size(size_t w, size_t h) {
11611161 Py_DECREF (res);
11621162}
11631163
1164- inline void legend () {
1164+ template <typename Vector = std::vector<double >>
1165+ inline void legend (const std::string &loc = " best" ,
1166+ const Vector &bbox_to_anchor = Vector()) {
11651167 detail::_interpreter::get ();
11661168
1169+ PyObject *kwargs = PyDict_New ();
1170+ PyDict_SetItemString (kwargs, " loc" , PyString_FromString (loc.c_str ()));
1171+
1172+ if (bbox_to_anchor.size () == 2 || bbox_to_anchor.size () == 4 ) {
1173+ PyObject *bbox = get_array (bbox_to_anchor);
1174+ PyDict_SetItemString (kwargs, " bbox_to_anchor" , bbox);
1175+ }
1176+
11671177 PyObject *res =
1168- PyObject_CallObject (detail::_interpreter::get ().s_python_function_legend ,
1169- detail::_interpreter::get ().s_python_empty_tuple );
1178+ PyObject_Call (detail::_interpreter::get ().s_python_function_legend ,
1179+ detail::_interpreter::get ().s_python_empty_tuple , kwargs);
1180+
1181+ Py_DECREF (kwargs);
1182+
11701183 if (!res)
11711184 throw std::runtime_error (" Call to legend() failed." );
11721185
You can’t perform that action at this time.
0 commit comments