Histogram and changing x-axis limits

Engelsma,> Why are the x-axis limits adjusted when I try to plot a
    Engelsma,> vertical line as a Control Limit?

Everytime you add some data to the plot, matplotlib recomputes the
axis limits. The quick fix for you is to set your xlim after all the
plot commands

    # the histogram of the data
    n, bins, patches = matplotlib.matlab.hist(histogram_data, 10, normed=0)
    # add a 'best fit' line
    y = matplotlib.matlab.normpdf(bins, average[i], std_dev[i])
    l = matplotlib.matlab.plot(bins, y, 'r--')
    matplotlib.matlab.set(l, 'linewidth', 2)
    matplotlib.matlab.ylabel('Number of Parts')
    matplotlib.matlab.title(PartNum + " -- " + PartDesc)
    matplotlib.matlab.set(matplotlib.matlab.gca(), 'xlim', [199, 205])

But it's not clear to me why the autoset would leave some of your data
offscreen - that shouldn't happen. I'll take a look at that code. Is
it possible for you to provide a complete example that replicates the

On an unrelated note, give that you like to use the fully qualified
names of all the functions, you might prefer the object oriented

    n, bins, patches = matplotlib.matlab.hist(histogram_data, 10, normed=0)
    ax = matplotlib.matlab.subplot(111)
    y = matplotlib.mlab.normpdf(bins, average[i], std_dev[i])
                    ^ normpdf is defined in mlab.py, not matlab.py

    lines = ax.plot(bins, y, 'r--')
    for line in lines:
    ax.set_ylabel('Number of Parts')
    ax.set_title(PartNum + " -- " + PartDesc)

    ax.set_xlim([199, 205])


Hope this helps,
John Hunter