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')
        histogram_data.fromlist(DimensionData)
        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:
                line.set_linewidth(1)

        # plot lines on histogram indicating upper & lower control limits along with
        #   nominal dimension.
        histogram.set_xlim([x_lowest, x_highest])
        histogram.plot([SC.LCL,SC.LCL],[0,max(n)],'b--')
        histogram.plot([SC.Nom,SC.Nom],[0,max(n)],'g--')
        histogram.plot([SC.UCL,SC.UCL],[0,max(n)],'r--')

        # Set axis labels
        histogram.set_xlabel(DataDesc)
        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])
       
        #matplotlib.matlab.savefig(filePath)
        matplotlib.matlab.show()
        matplotlib.matlab.close()

Any ideas?

Thanks in advance,

Dave Engelsma
Lacks Wheel Trim Systems