[python] matplotlib: improve 'grid'

This commit is contained in:
Émilie Feral
2020-03-26 14:45:29 +01:00
parent 1b768ba34a
commit 9a240bb0b4
3 changed files with 9 additions and 6 deletions

View File

@@ -121,11 +121,14 @@ mp_obj_t modpyplot_bar(mp_obj_t x, mp_obj_t height) {
return mp_const_none;
}
mp_obj_t modpyplot_grid(mp_obj_t b) {
if (mp_obj_is_type(b, &mp_type_bool)) {
sPlotStore->setGridRequested(mp_obj_is_true(b));
} else {
mp_obj_t modpyplot_grid(size_t n_args, const mp_obj_t *args) {
assert(sPlotStore != nullptr);
if (n_args == 0) {
// Toggle the grid visibility
sPlotStore->setGridRequested(!sPlotStore->gridRequested());
} else {
sPlotStore->setGridRequested(mp_obj_is_true(args[0]));
}
return mp_const_none;
}