def barh(x, labels=None, fig=None, **kwargs): kwargs.update({"xlabel": get_label(x)}) fig, show = check_fig(fig, **kwargs) fig.barh(x, labels=labels, **kwargs) return return_plt(fig, show, **kwargs)
def plot(x, y, fig=None, **kwargs): x_label, y_label = get_label(x), get_label(y) if isinstance(y_label, list): # multi label goes into legend if kwargs.get("label") is None: kwargs.update({"label": y_label}) elif isinstance(y_label, str): # single label goes into axis labels if kwargs.get("ylabel") is None: kwargs.update({"ylabel": y_label}) if kwargs.get("xlabel") is None: kwargs.update({"xlabel": x_label}) fig, show = check_fig(fig, **kwargs) fig.plot(x, y, **kwargs) return return_plt(fig, show, **kwargs)
def boxplot(x, labels=None, fig=None, **kwargs): if labels is None: labels = get_label(x) fig, show = check_fig(fig, **kwargs) fig.boxplot(x, labels=labels, **kwargs) return return_plt(fig, show, **kwargs)
def hist(x, bins=10, fig=None, **kwargs): if kwargs.get("xlabel") is None: kwargs.update({"xlabel": get_label(x)}) if kwargs.get("ylabel") is None: kwargs.update({"ylabel": "counts"}) fig, show = check_fig(fig, **kwargs) fig.hist(x, bins=bins, **kwargs) return return_plt(fig, show, **kwargs)
def test_get_label(x, expected_label): label = get_label(x) assert label == expected_label