File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -2615,6 +2615,29 @@ inline void pause(Numeric interval)
2615
2615
Py_DECREF (res);
2616
2616
}
2617
2617
2618
+ inline void savefig (const std::string &filename,
2619
+ const std::map<std::string, std::string> &keywords = {}) {
2620
+ PyObject *pyfilename = PyString_FromString (filename.c_str ());
2621
+
2622
+ PyObject *args = PyTuple_New (1 );
2623
+ PyTuple_SetItem (args, 0 , pyfilename);
2624
+
2625
+ PyObject *kwargs = PyDict_New ();
2626
+ for (auto it = keywords.begin (); it != keywords.end (); ++it) {
2627
+ PyDict_SetItemString (kwargs, it->first .c_str (),
2628
+ PyUnicode_FromString (it->second .c_str ()));
2629
+ }
2630
+
2631
+ PyObject *res = PyObject_Call (
2632
+ detail::_interpreter::get ().s_python_function_save , args, kwargs);
2633
+ if (!res)
2634
+ throw std::runtime_error (" Call to save() failed." );
2635
+
2636
+ Py_DECREF (kwargs);
2637
+ Py_DECREF (args);
2638
+ Py_DECREF (res);
2639
+ }
2640
+
2618
2641
inline void save (const std::string& filename, const int dpi=0 )
2619
2642
{
2620
2643
detail::_interpreter::get ();
You can’t perform that action at this time.
0 commit comments