diff --git a/python/port/mod/matplotlib/pyplot/modpyplot.cpp b/python/port/mod/matplotlib/pyplot/modpyplot.cpp index 805edce29..2e27fe0ac 100644 --- a/python/port/mod/matplotlib/pyplot/modpyplot.cpp +++ b/python/port/mod/matplotlib/pyplot/modpyplot.cpp @@ -251,14 +251,14 @@ mp_obj_t modpyplot_grid(size_t n_args, const mp_obj_t *args) { return mp_const_none; } -/* hist(x, bins, color) +/* hist(x, bins KW : color) * 'x' array * 'bins': (default value 10) * - int (number of bins) * - sequence of bins * */ -mp_obj_t modpyplot_hist(size_t n_args, const mp_obj_t *args) { +mp_obj_t modpyplot_hist(size_t n_args, const mp_obj_t *args, mp_map_t* kw_args ) { assert(sPlotStore != nullptr); sPlotStore->setShow(true); // Sort data to easily get the minimal and maximal value and count bin sizes @@ -330,7 +330,10 @@ mp_obj_t modpyplot_hist(size_t n_args, const mp_obj_t *args) { binIndex++; } - KDColor color = colorFromOptionalArgumentAtIndex(n_args, args, 2); + // Setting hist color + mp_map_elem_t * elem = mp_map_lookup(kw_args, MP_OBJ_NEW_QSTR(MP_QSTR_color), MP_MAP_LOOKUP); + KDColor color = colorFromKeywordArgument(elem); + for (size_t i=0; iaddRect(edgeItems[i], edgeItems[i+1], binItems[i], mp_obj_new_float(0.0), color); } diff --git a/python/port/mod/matplotlib/pyplot/modpyplot.h b/python/port/mod/matplotlib/pyplot/modpyplot.h index 6e5c2f466..49a2c9a61 100644 --- a/python/port/mod/matplotlib/pyplot/modpyplot.h +++ b/python/port/mod/matplotlib/pyplot/modpyplot.h @@ -8,7 +8,7 @@ mp_obj_t modpyplot_arrow(size_t n_args, const mp_obj_t *args, mp_map_t* kw_args) mp_obj_t modpyplot_axis(size_t n_args, const mp_obj_t *args); mp_obj_t modpyplot_bar(size_t n_args, const mp_obj_t *args, mp_map_t* kw_args); mp_obj_t modpyplot_grid(size_t n_args, const mp_obj_t *args); -mp_obj_t modpyplot_hist(size_t n_args, const mp_obj_t *args); +mp_obj_t modpyplot_hist(size_t n_args, const mp_obj_t *args, mp_map_t* kw_args); mp_obj_t modpyplot_plot(size_t n_args, const mp_obj_t *args); mp_obj_t modpyplot_scatter(size_t n_args, const mp_obj_t *args); mp_obj_t modpyplot_text(mp_obj_t x, mp_obj_t y, mp_obj_t s); diff --git a/python/port/mod/matplotlib/pyplot/modpyplot_table.c b/python/port/mod/matplotlib/pyplot/modpyplot_table.c index 52dd41364..d5c25232f 100644 --- a/python/port/mod/matplotlib/pyplot/modpyplot_table.c +++ b/python/port/mod/matplotlib/pyplot/modpyplot_table.c @@ -5,7 +5,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_KW(modpyplot_arrow_obj, 4, modpyplot_arrow); STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(modpyplot_axis_obj, 0, 1, modpyplot_axis); STATIC MP_DEFINE_CONST_FUN_OBJ_KW(modpyplot_bar_obj, 2, modpyplot_bar); STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(modpyplot_grid_obj, 0, 1, modpyplot_grid); -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(modpyplot_hist_obj, 1, 3, modpyplot_hist); +STATIC MP_DEFINE_CONST_FUN_OBJ_KW(modpyplot_hist_obj, 1, modpyplot_hist); STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(modpyplot_plot_obj, 1, 3, modpyplot_plot); STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(modpyplot_scatter_obj, 2, 3, modpyplot_scatter); STATIC MP_DEFINE_CONST_FUN_OBJ_0(modpyplot_show_obj, modpyplot_show);