Histograms with negative data

Histograms with negative data
Hello -

I’m creating a histogram with a negative data values (30 values between -1.5 and -0.5). The histogram is created, however the data is plotted as if the values were forced positive (i.e. forced to absolute values).

I’ve checked exactly what data is being passed to the hist function and the data goes in as a series of negative values.

The Python code:

Generate chart using matplotlib library

    histogram_data = array.array('f')


    overall_range = max(DimensionData) - min(DimensionData)

    x_lowest = min(DimensionData) - (2*overall_range)

    x_highest = max(DimensionData) + (2*overall_range)

the histogram of the data

    n, bins, patches = matplotlib.matlab.hist(histogram_data, 10, normed=0)

    histogram = matplotlib.matlab.subplot(111)

add a ‘best fit’ line

    y = matplotlib.mlab.normpdf(bins, SC.meanVal, SC.stdDev)

    lines = histogram.plot(bins, y, 'r-')

    for line in lines:


plot lines on histogram indicating upper & lower control limits along with

    #   nominal dimension.

    histogram.set_xlim([x_lowest, x_highest])




Set axis labels


    histogram.set_ylabel('Number of Parts')

Setup strings for chart legend

    LegUCL = "UCL: " + str(SC.UCL)

    LegNom = "Nominal: " + str(SC.Nom)

    LegLCL = "LCL: " + str(SC.LCL)

histogram.legend([“Curve”, LegLCL, LegNom, LegUCL],fontsize = 10)

    histogram.set_xlim([x_lowest, x_highest])




Any ideas?

Thanks in advance,

Dave Engelsma

Lacks Wheel Trim Systems