Skip to content

Commit

Permalink
API plot: default to not plotting legend for single category
Browse files Browse the repository at this point in the history
  • Loading branch information
christianbrodbeck committed Apr 29, 2021
1 parent 65c003e commit 6a0b757
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
10 changes: 8 additions & 2 deletions eelbrain/plot/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2858,11 +2858,17 @@ def __init__(self, loc, handles, labels=None):
labels : dict
Dictionary with labels for cells.
"""
# whether to plot default legend
if loc is not None:
initial_loc = loc
elif len(handles) > 1:
initial_loc = 'upper right'
else:
initial_loc = False
self.__handles = handles
self.legend = None
self.__labels = copy(labels)
if self.__handles:
self.plot_legend(loc, labels)
self.plot_legend(initial_loc, labels)

def _fill_toolbar(self, tb):
from .._wxgui import wx
Expand Down
4 changes: 2 additions & 2 deletions eelbrain/plot/_uts.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def __init__(
main: Callable = np.mean,
error: str = 'sem',
pool_error: bool = None,
legend: Union[str, int, bool] = 'upper right',
legend: Union[str, int, bool] = None,
labels: Dict[CellArg, str] = None,
axtitle: Union[bool, Sequence[str]] = True,
xlabel: Union[bool, str] = True,
Expand Down Expand Up @@ -371,7 +371,7 @@ def __init__(
yticklabels: Union[str, int, Sequence[int]] = 'left',
bottom: float = None,
top: float = None,
legend: Union[str, int, bool] = 'upper right',
legend: Union[str, int, bool] = None,
labels: Dict[CellArg, str] = None,
xlim: Union[float, Tuple[float, float]] = None,
colors: Union[Any, dict] = None,
Expand Down
6 changes: 3 additions & 3 deletions eelbrain/plot/_uv.py
Original file line number Diff line number Diff line change
Expand Up @@ -826,7 +826,7 @@ def __init__(
xlabel: Union[bool, str] = True,
ylabel: Union[bool, str] = True,
timelabels: Union[Sequence, Dict, str] = None,
legend: Union[str, int, bool] = 'upper right',
legend: Union[str, int, bool] = None,
labels: Dict = None,
colors: ColorsArg = None,
**kwargs,
Expand Down Expand Up @@ -1054,7 +1054,7 @@ def __init__(
vmin: str = None,
vmax: str = None,
markers: str = None,
legend: Union[str, int, bool] = 'upper right',
legend: Union[str, int, bool] = None,
labels: dict = None,
alpha: float = 1.,
xlabel: Union[bool, str] = True,
Expand Down Expand Up @@ -1159,7 +1159,7 @@ def __init__(
xlabel: Union[bool, str] = True,
ylabel: Union[bool, str] = True,
alpha: float = .2,
legend: Union[str, int, bool] = 'upper right',
legend: Union[str, int, bool] = None,
labels: dict = None,
c: Any = ('#009CFF', '#FF7D26', '#54AF3A', '#FE58C6', '#20F2C3'),
**kwargs):
Expand Down

0 comments on commit 6a0b757

Please sign in to comment.