@@ -955,7 +955,21 @@ inline void imshow(void* ptr, const NPY_TYPES type, const int rows, const int co
955
955
for (std::map<std::string, std::string>::const_iterator it = keywords.begin ();
956
956
it != keywords.end (); ++it) {
957
957
if (it->first == " extent" ) {
958
+ std::stringstream ss (it->second );
959
+ double ext[4 ];
960
+ int i = 0 ;
961
+ while (ss.good ()) {
962
+ std::string substr;
963
+ getline (ss, substr, ' ,' );
964
+ ext[i] = std::stod (substr);
965
+ i++;
958
966
}
967
+ PyDict_SetItemString (kwargs, it->first .c_str (),
968
+ Py_BuildValue (" (dddd)" , ext[0 ], ext[1 ], ext[2 ], ext[3 ]));
969
+ } else {
970
+ PyDict_SetItemString (kwargs, it->first .c_str (),
971
+ PyUnicode_FromString (it->second .c_str ()));
972
+ }
959
973
}
960
974
961
975
PyObject* res =
@@ -984,6 +998,11 @@ inline void imshow(const float* ptr, const int rows, const int columns, const in
984
998
}
985
999
986
1000
inline void imshow (const double * ptr, const int rows, const int columns, const int colors,
1001
+ const std::map<std::string, std::string>& keywords = {},
1002
+ PyObject** out = nullptr ) {
1003
+ detail::imshow ((void *)ptr, NPY_DOUBLE, rows, columns, colors, keywords, out);
1004
+ }
1005
+
987
1006
#ifdef WITH_OPENCV
988
1007
void imshow (const cv::Mat& image, const std::map<std::string, std::string>& keywords = {}) {
989
1008
// Convert underlying type of matrix, if needed
@@ -2277,7 +2296,23 @@ inline void subplot(long nrows, long ncols, long plot_number) {
2277
2296
Py_DECREF (res);
2278
2297
}
2279
2298
2299
+ inline void subplot (long plot_number) {
2300
+ detail::_interpreter::get ();
2301
+
2302
+ // construct positional args
2303
+ PyObject* args = PyTuple_New (1 );
2304
+ // PyTuple_SetItem(args, 0, PyFloat_FromDouble(nrows));
2305
+ // PyTuple_SetItem(args, 1, PyFloat_FromDouble(ncols));
2306
+ PyTuple_SetItem (args, 0 , PyInt_FromLong (plot_number));
2307
+
2308
+ PyObject* res =
2309
+ PyObject_CallObject (detail::_interpreter::get ().s_python_function_subplot , args);
2280
2310
if (!res) throw std::runtime_error (" Call to subplot() failed." );
2311
+
2312
+ Py_DECREF (args);
2313
+ Py_DECREF (res);
2314
+ }
2315
+
2281
2316
inline void subplot2grid (long nrows, long ncols, long rowid = 0 , long colid = 0 , long rowspan = 1 ,
2282
2317
long colspan = 1 ) {
2283
2318
detail::_interpreter::get ();
0 commit comments