Skip to content

Commit

Permalink
hline method
Browse files Browse the repository at this point in the history
  • Loading branch information
thibaultfalque committed Jun 2, 2023
1 parent 94ecdb2 commit 1d54833
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
3 changes: 3 additions & 0 deletions autograph/core/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,9 @@ def _set_latex(self, value):
def plot(self, x, y, label=None, style: Optional[PlotStyle] = None):
raise NotImplementedError

def hline(self, y, label=None, style: Optional[PlotStyle] = None):
raise NotImplementedError

@abstractmethod
def scatter(self, x, y, label=None, style: Optional[PlotStyle] = None):
raise NotImplementedError
Expand Down
13 changes: 10 additions & 3 deletions autograph/wrapper/mpl.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,15 +150,22 @@ def save(self, output, **kwargs):
def plot(self, x, y, label=None, style: Optional[PlotStyle] = None):
self._internal_plot(x, y, label, style, self._ax.plot)

def hline(self, y, label=None, style: Optional[PlotStyle] = None):
if style is None:
self._ax.axhline(y, label=label)
else:
kwargs = self._style_as_kwargs(style)
self._ax.axhline(y, label=label, **kwargs)

def boxplot(self, x, labels=None, style: BoxStyle = BoxStyle()):
self._ax.boxplot(x, labels=labels, meanline=style.mean_line, showmeans=style.show_mean,
vert=style.vert)

def barplot(self, x, y, data, category=None,estimator=sum):
def barplot(self, x, y, data, category=None, estimator=sum):
if category is not None:
self._ax = sns.barplot(x, y, data=data, hue=category, ax=self._ax,estimator=estimator)
self._ax = sns.barplot(x=x, y=y, data=data, hue=category, ax=self._ax, estimator=estimator)
else:
self._ax = sns.barplot(x, y, data=data, ax=self._ax,estimator=estimator)
self._ax = sns.barplot(x=x, y=y, data=data, ax=self._ax, estimator=estimator)

def heatmap(self, data):
self._ax = sns.heatmap(data, ax=self._ax)
Expand Down

0 comments on commit 1d54833

Please sign in to comment.