Skip to content

Commit

Permalink
Make it more pythonic
Browse files Browse the repository at this point in the history
  • Loading branch information
mvdoc committed Aug 23, 2016
1 parent 13dcaa0 commit 5c5bb01
Showing 1 changed file with 8 additions and 20 deletions.
28 changes: 8 additions & 20 deletions mvpa2/misc/plot/scatter.py
Expand Up @@ -391,25 +391,19 @@ def jitter_me(x, w):
if ylim is not None:
ax_scatter.set_ylim( ylim )

# TODO: these histograms disregard masking, but they should not
# actually consider masked-out values
# get values to plot for histogram and boxplot
x_hist, y_hist = (x, y) if mask is None else (x_masked, y_masked)

if ax_hist_x is not None:
ax_hist_x.xaxis.set_major_formatter(nullfmt)
if mask is not None:
histx = ax_hist_x.hist(x_masked, bins=binsx, facecolor='b')
else:
histx = ax_hist_x.hist(x, bins=binsx, facecolor='b')
histx = ax_hist_x.hist(x_hist, bins=binsx, facecolor='b')
ax_hist_x.set_xlim( ax_scatter.get_xlim() )
ax_hist_x.vlines(0, 0, 0.9*np.max(histx[0]), 'r')

if ax_hist_y is not None:
ax_hist_y.yaxis.set_major_formatter(nullfmt)
if mask is not None:
histy = ax_hist_y.hist(y_masked, bins=binsy,
orientation='horizontal', facecolor='g')
else:
histy = ax_hist_y.hist(y, bins=binsy,
orientation='horizontal', facecolor='g')
histy = ax_hist_y.hist(y_hist, bins=binsy,
orientation='horizontal', facecolor='g')
ax_hist_y.set_ylim( ax_scatter.get_ylim() )
ax_hist_y.hlines(0, 0, 0.9*np.max(histy[0]), 'r')

Expand All @@ -418,18 +412,12 @@ def jitter_me(x, w):
# Box plots
if ax_bp_x is not None:
ax_bp_x.axis('off')
if mask is not None:
bpx = ax_bp_x.boxplot(x_masked, vert=0) #'r', 0)
else:
bpx = ax_bp_x.boxplot(x, vert=0) #'r', 0)
bpx = ax_bp_x.boxplot(x_hist, vert=0) #'r', 0)
ax_bp_x.set_xlim(ax_scatter.get_xlim())

if ax_bp_y is not None:
ax_bp_y.axis('off')
if mask is not None:
bpy = ax_bp_y.boxplot(y_masked, sym='g+')
else:
bpy = ax_bp_y.boxplot(y, sym='g+')
bpy = ax_bp_y.boxplot(y_hist, sym='g+')
ax_bp_y.set_ylim(ax_scatter.get_ylim())

if statsline:
Expand Down

0 comments on commit 5c5bb01

Please sign in to comment.