Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions datascience/tables.py
Original file line number Diff line number Diff line change
Expand Up @@ -1316,11 +1316,8 @@ def plot(self, column_for_xticks, overlay=False, **vargs):
options = self.default_options.copy()
options.update(vargs)

# Note that the labels here get incorrectly placed on the x-axis even
# though the labels describe the y-axis values.
# TODO(sam): Allow _visualize to accept options to put labels on both x
# and y axes.
xticks, labels = self._split_by_column(column_for_xticks)
labels = [(column_for_xticks, y) for y in labels]

def draw(axis, label, color):
if xticks is None:
Expand Down Expand Up @@ -1400,6 +1397,7 @@ def scatter(self, column_for_x, overlay=False, fit_line=False, **vargs):
options = self.default_options.copy()
options.update(vargs)
xdata, labels = self._split_by_column(column_for_x)
labels = [(column_for_x, y) for y in labels]

def draw(axis, label, color):
axis.scatter(xdata, self[label], color=color, **options)
Expand Down Expand Up @@ -1492,6 +1490,7 @@ def barh(self, column_for_categories, overlay=False, **vargs):
raise ValueError("The column '{0}' contains non-numerical "
"values. A bar graph cannot be drawn for this table."
.format(label))
labels = [(column_for_categories, y) for y in labels]

index = np.arange(self.num_rows)
margin = 0.1
Expand Down Expand Up @@ -1560,6 +1559,7 @@ def bar(self, column_for_categories=None, overlay=False, **vargs):
raise ValueError("The column '{0}' contains non-numerical "
"values. A bar graph cannot be drawn for this table."
.format(label))
labels = [(column_for_categories, y) for y in labels]

index = np.arange(self.num_rows)
margin = 0.1
Expand Down Expand Up @@ -1597,8 +1597,13 @@ def _visualize(self, labels, ticks, overlay, draw, annotate, width=6, height=4):
if not isinstance(axes, collections.Iterable):
axes=[axes]
for axis, label, color in zip(axes, labels, colors):
draw(axis, label, color)
axis.set_xlabel(label, fontsize=16)
if isinstance(label, tuple):
draw(axis, label[1], color)
axis.set_xlabel(label[0], fontsize=16)
axis.set_ylabel(label[1], fontsize=16)
else:
draw(axis, label, color)
axis.set_xlabel(label, fontsize=16)
if ticks is not None:
annotate(axis, ticks)

Expand Down