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) {
1161
1161
Py_DECREF (res);
1162
1162
}
1163
1163
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()) {
1165
1167
detail::_interpreter::get ();
1166
1168
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
+
1167
1177
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
+
1170
1183
if (!res)
1171
1184
throw std::runtime_error (" Call to legend() failed." );
1172
1185
You can’t perform that action at this time.
0 commit comments