Skip to content

Commit

Permalink
ENH plot.ColorGrid: only tilt column labels if len > 1
Browse files Browse the repository at this point in the history
  • Loading branch information
christianbrodbeck committed Jan 30, 2017
1 parent ce041b3 commit b5545df
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions eelbrain/plot/_colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,25 +268,28 @@ def __init__(self, row_cells, column_cells, colors, size=None,
row_labels = row_cells

# column labels
tilt_labels = any(len(label) > 1 for label in column_labels)
self._labels = []
if column_label_position == 'top':
y = n_rows + 0.1
va = 'bottom'
rotation = 40
rotation = 40 if tilt_labels else 0
ymin = 0
ymax = self._layout.h / size
elif column_label_position == 'bottom':
y = -0.1
va = 'top'
rotation = -40
rotation = -40 if tilt_labels else 0
ymax = n_rows
ymin = n_rows - self._layout.h / size
else:
msg = "column_label_position=%s" % repr(column_label_position)
raise ValueError(msg)

for col, label in enumerate(column_labels):
h = ax.text(col + 0.5, y, label, va=va, ha='left', rotation=rotation)
h = ax.text(col + 0.5, y, label, va=va,
ha='left' if tilt_labels else 'center',
rotation=rotation)
self._labels.append(h)

# row labels
Expand Down

0 comments on commit b5545df

Please sign in to comment.