@@ -70,6 +70,8 @@ struct _interpreter {
70
70
PyObject *s_python_function_subplot2grid;
71
71
PyObject *s_python_function_legend;
72
72
PyObject *s_python_function_xlim;
73
+ PyObject *s_python_function_set_xscale;
74
+ PyObject *s_python_function_set_yscale;
73
75
PyObject *s_python_function_ion;
74
76
PyObject *s_python_function_ginput;
75
77
PyObject *s_python_function_ylim;
@@ -246,6 +248,8 @@ struct _interpreter {
246
248
s_python_function_subplot2grid = safe_import (pymod, " subplot2grid" );
247
249
s_python_function_legend = safe_import (pymod, " legend" );
248
250
s_python_function_xlim = safe_import (pymod, " xlim" );
251
+ s_python_function_set_xscale = safe_import (pymod, " set_xscale" );
252
+ s_python_function_set_yscale = safe_import (pymod, " set_yscale" );
249
253
s_python_function_ylim = safe_import (pymod, " ylim" );
250
254
s_python_function_title = safe_import (pymod, " title" );
251
255
s_python_function_axis = safe_import (pymod, " axis" );
@@ -883,6 +887,52 @@ bool arrow(Numeric x, Numeric y, Numeric end_x, Numeric end_y, const std::string
883
887
return res;
884
888
}
885
889
890
+ void set_xscale (std::string value,
891
+ const std::map<std::string, std::string> &keywords = {})
892
+ {
893
+ detail::_interpreter::get ();
894
+
895
+ PyObject* pystr = PyString_FromString (value.c_str ());
896
+ PyObject* args = PyTuple_New (1 );
897
+ PyTuple_SetItem (args, 0 , pystr);
898
+
899
+ PyObject* kwargs = PyDict_New ();
900
+ for (auto it = keywords.begin (); it != keywords.end (); ++it) {
901
+ PyDict_SetItemString (kwargs, it->first .c_str (), PyUnicode_FromString (it->second .c_str ()));
902
+ }
903
+
904
+ PyObject* res = PyObject_Call (detail::_interpreter::get ().s_python_function_set_xscale , args, kwargs);
905
+
906
+ if (!res) throw std::runtime_error (" Call to set_xscale() failed." );
907
+
908
+ Py_DECREF (args);
909
+ Py_DECREF (kwargs);
910
+ Py_DECREF (res);
911
+ }
912
+
913
+ void set_yscale (std::string value,
914
+ const std::map<std::string, std::string> &keywords = {})
915
+ {
916
+ detail::_interpreter::get ();
917
+
918
+ PyObject* pystr = PyString_FromString (value.c_str ());
919
+ PyObject* args = PyTuple_New (1 );
920
+ PyTuple_SetItem (args, 0 , pystr);
921
+
922
+ PyObject* kwargs = PyDict_New ();
923
+ for (auto it = keywords.begin (); it != keywords.end (); ++it) {
924
+ PyDict_SetItemString (kwargs, it->first .c_str (), PyUnicode_FromString (it->second .c_str ()));
925
+ }
926
+
927
+ PyObject* res = PyObject_Call (detail::_interpreter::get ().s_python_function_set_yscale , args, kwargs);
928
+
929
+ if (!res) throw std::runtime_error (" Call to set_yscale() failed." );
930
+
931
+ Py_DECREF (args);
932
+ Py_DECREF (kwargs);
933
+ Py_DECREF (res);
934
+ }
935
+
886
936
template < typename Numeric>
887
937
bool hist (const std::vector<Numeric>& y, long bins=10 ,std::string color=" b" ,
888
938
double alpha=1.0 , bool cumulative=false )
0 commit comments