Skip to content

Commit

Permalink
Add plt.show() to all plotting calls
Browse files Browse the repository at this point in the history
This doesn't change current behavior at all. However, without it the
plot gets displayed multiple times when using IPython's widgets as I'm
discovering now.

I've tested this by calling each plot method and verifying that the
notebook is the same. In addition, I've verified that using an IPython
widget does not duplicate plots when redrawn.
  • Loading branch information
SamLau95 committed Mar 3, 2017
1 parent 7a7ca82 commit f3fa095
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions datascience/tables.py
Expand Up @@ -2276,6 +2276,7 @@ def _visualize(self, x_label, y_labels, ticks, overlay, draw, annotate, width=6,
if ticks is not None:
annotate(axis, ticks)
type(self).plots.append(axis)
plt.show()

def _split_column_and_labels(self, column_or_label):
"""Return the specified column and labels of other columns."""
Expand Down Expand Up @@ -2313,6 +2314,7 @@ def pivot_hist(self, pivot_column_label, value_column_label, overlay=True, width
t['end'] = bins[1:]
for label, column in zip(pvt_labels,vals):
t[label] = column
plt.show()

def hist(self, *columns, overlay=True, bins=None, bin_column=None, unit=None, counts=None, width=6, height=4, **vargs):
"""Plots one histogram for each column in columns. If no column is
Expand Down Expand Up @@ -2440,6 +2442,7 @@ def hist(self, *columns, overlay=True, bins=None, bin_column=None, unit=None, co
axis.hist(values, color=color, **vargs)
_vertical_x(axis)
type(self).plots.append(axis)
plt.show()

def boxplot(self, **vargs):
"""Plots a boxplot for the table.
Expand Down Expand Up @@ -2487,6 +2490,7 @@ def boxplot(self, **vargs):
vargs['labels'] = columns.keys()
values = list(columns.values())
plt.boxplot(values, **vargs)
plt.show()


###########
Expand Down

0 comments on commit f3fa095

Please sign in to comment.