@@ -94,6 +94,7 @@ struct _interpreter {
94
94
PyObject *s_python_function_bar;
95
95
PyObject *s_python_function_subplots_adjust;
96
96
PyObject *s_python_function_imshow;
97
+ PyObject *s_python_function_colorbar;
97
98
98
99
/* For now, _interpreter is implemented as a singleton since its currently not
99
100
possible to have multiple independent embedded python interpreters without
@@ -229,12 +230,13 @@ struct _interpreter {
229
230
s_python_function_subplots_adjust =
230
231
PyObject_GetAttrString (pymod, " subplots_adjust" );
231
232
s_python_function_imshow = PyObject_GetAttrString (pymod, " imshow" );
233
+ s_python_function_colorbar = PyObject_GetAttrString (pymod, " colorbar" );
232
234
233
235
if (!s_python_function_show || !s_python_function_close ||
234
236
!s_python_function_draw || !s_python_function_pause ||
235
237
!s_python_function_figure || !s_python_function_fignum_exists ||
236
238
!s_python_function_plot || !s_python_function_quiver ||
237
- !s_python_function_contour ||
239
+ !s_python_function_contour || !s_python_function_colorbar ||
238
240
!s_python_function_semilogx || !s_python_function_semilogy ||
239
241
!s_python_function_loglog || !s_python_function_fill ||
240
242
!s_python_function_fill_between || !s_python_function_subplot ||
@@ -296,7 +298,8 @@ struct _interpreter {
296
298
!PyFunction_Check (s_python_function_suptitle) ||
297
299
!PyFunction_Check (s_python_function_bar) ||
298
300
!PyFunction_Check (s_python_function_subplots_adjust) ||
299
- !PyFunction_Check (s_python_function_imshow)
301
+ !PyFunction_Check (s_python_function_imshow) ||
302
+ !PyFunction_Check (s_python_function_colorbar)
300
303
) {
301
304
throw std::runtime_error (
302
305
" Python object is unexpectedly not a PyFunction." );
@@ -686,6 +689,15 @@ void imshow(const Matrix& X, const std::map<std::string, std::string> &keywords
686
689
Py_DECREF (res);
687
690
}
688
691
692
+ // @brief Add the colorbar
693
+ void colorbar () {
694
+ PyObject *res =
695
+ PyObject_CallObject (detail::_interpreter::get ().s_python_function_colorbar ,
696
+ detail::_interpreter::get ().s_python_empty_tuple );
697
+ if (!res)
698
+ throw std::runtime_error (" Call to colorbar() failed." );
699
+ }
700
+
689
701
// @brief plot_surface for datapoints (x_ij, y_ij, z_ij) with i,j = 0..n
690
702
// @param x The x values of the datapoints in a matrix
691
703
// @param y The y values of the datapoints in a matrix
0 commit comments