0

I have an aesthetic issue when plotting multiple cumulative histograms in python on the same axes. The histograms will end with the final bin rather than continuing until the terminal axis.

Thus when I plot differing populations, to visually show a KS statistic, it ends up looking mediocre.ugly_histogram.png

Edit: as per tom's suggestion, minimal working code.

import pylab as pl
import random as rnd

x1 = [rnd.gauss(0,7) for a in range(100)]
x2 = [rnd.gauss(-3,1) for a in range(100)]
x3 = [rnd.gauss(3,3) for a in range(100)]

pl.hist(x1, cumulative=True, histtype='stepfilled', alpha=0.25)
pl.hist(x2, cumulative=True, histtype='stepfilled', alpha=0.25)
pl.hist(x3, cumulative=True, histtype='stepfilled', alpha=0.25)

pl.show()

Aesthetically, the image should have the histograms continuing on both sides to the ends of the axis, as in the wikipedia image:

wikipedia KS test image

stellographer
  • 373
  • 3
  • 11
  • 2
    you'l get better/quicker help if you give a [minimal working example](http://stackoverflow.com/help/MCVE) of your code – tmdavison Oct 12 '15 at 09:50
  • Think this may be a duplicate of http://stackoverflow.com/questions/10690094/cumulative-histogram-has-last-point-at-y-0? – Ed Smith Oct 12 '15 at 12:19
  • Mmm, not a repeat (of that question at least). That question is about how to create a histogram data structure. My question is about the aesthetics of the matplotlib histogram plotting function. – stellographer Oct 13 '15 at 02:46

0 Answers0