mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[matplotlib/modpyplot.cpp] Adding keyword arguments support for bar function
bar function can now take into account the following keywords arguments : - color Change-Id: Iefa68cff59986d89c37cfecd7e3750f03c33ca59
This commit is contained in:
committed by
Émilie Feral
parent
41da4f2bd5
commit
0e3684e137
@@ -174,16 +174,14 @@ mp_obj_t modpyplot_axis(size_t n_args, const mp_obj_t *args) {
|
||||
return mp_obj_new_tuple(4, coords);
|
||||
}
|
||||
|
||||
/* bar(x, height, width, bottom, color)
|
||||
/* bar(x, height, width, bottom, KW :color)
|
||||
* 'x', 'height', 'width' and 'bottom' can either be a scalar or an array/tuple of
|
||||
* scalar.
|
||||
* 'width' default value is 0.8
|
||||
* 'bottom' default value is None
|
||||
* */
|
||||
|
||||
// TODO: accept keyword args?
|
||||
|
||||
mp_obj_t modpyplot_bar(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) {
|
||||
assert(sPlotStore != nullptr);
|
||||
sPlotStore->setShow(true);
|
||||
mp_obj_t * xItems;
|
||||
@@ -215,7 +213,10 @@ mp_obj_t modpyplot_bar(size_t n_args, const mp_obj_t *args) {
|
||||
bItems[0] = mp_obj_new_float(0.0f);
|
||||
}
|
||||
|
||||
KDColor color = colorFromOptionalArgumentAtIndex(n_args, args, 4);
|
||||
// Setting bar 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; i<xLength; i++) {
|
||||
mp_obj_t iH = hItems[hLength > 1 ? i : 0];
|
||||
mp_obj_t iW = wItems[wLength > 1 ? i : 0];
|
||||
|
||||
@@ -6,7 +6,7 @@ void modpyplot_flush_used_heap();
|
||||
|
||||
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_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_plot(size_t n_args, const mp_obj_t *args);
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_0(modpyplot___init___obj, modpyplot___init__);
|
||||
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_VAR_BETWEEN(modpyplot_bar_obj, 2, 5, modpyplot_bar);
|
||||
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_VAR_BETWEEN(modpyplot_plot_obj, 1, 3, modpyplot_plot);
|
||||
|
||||
Reference in New Issue
Block a user