# HG changeset patch # User Jordi GutiƩrrez Hermoso # Date 1463452050 14400 # Node ID 874eb082366004b69d8c26dd51842ddac67d4e56 # Parent 242afe8021b463b5c0a18315974a88cd00e21b7f plots: ensure that adjusted boxplots use the same scale diff --git a/talk/code/plots.py b/talk/code/plots.py --- a/talk/code/plots.py +++ b/talk/code/plots.py @@ -12,6 +12,17 @@ histheight = 0.75*height boxheight = 0.25*height + # setup the figure and axes + histAx = fig.add_axes([left, bottom, width, histheight]) + bpAx = fig.add_axes([left, bottom+histheight, width, boxheight]) + + # plot stuff + bpAx.bxp(data_stats, vert=False, flierprops={"marker": 'x'}) + histAx.hist(data, bins=bins, color=colour) + + + xlims = np.array([bpAx.get_xlim(), histAx.get_xlim()]) + # Do an adjusted boxplot if adjusted: mc = medcouple_1d(data) @@ -33,17 +44,10 @@ if (flier < data_stats[0]['whislo'] or flier > data_stats[0]['whishi']) ] - - # setup the figure and axes - histAx = fig.add_axes([left, bottom, width, histheight]) - bpAx = fig.add_axes([left, bottom+histheight, width, boxheight]) - - # plot stuff - bpAx.bxp(data_stats, vert=False, flierprops={"marker": 'x'}) - histAx.hist(data, bins=bins, color=colour) + bpAx.cla() + bpAx.bxp(data_stats, vert=False, flierprops={"marker": 'x'}) # confirm that the axes line up - xlims = np.array([bpAx.get_xlim(), histAx.get_xlim()]) for ax in [bpAx, histAx]: ax.set_xlim([xlims.min(), xlims.max()]) @@ -63,7 +67,7 @@ with open("../../data/women") as f: women = [float(x) for x in f.readlines()] -fig = plt.figure(figsize=(12,8)) + xticks = np.arange(5,105,5) bins = 0.5 + np.arange(0,100)