From: John H. <jdh...@ac...> - 2004-01-22 21:54:30
|
>>>>> "Engelsma," == Engelsma, Dave <D.E...@La...> writes: 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.xlabel(DataDescription[i]) matplotlib.matlab.ylabel('Number of Parts') matplotlib.matlab.plot([201,201],[0,40],'k--') matplotlib.matlab.title(PartNum + " -- " + PartDesc) matplotlib.matlab.set(matplotlib.matlab.gca(), 'xlim', [199, 205]) matplotlib.matlab.show() 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 problem? On an unrelated note, give that you like to use the fully qualified names of all the functions, you might prefer the object oriented interface 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: line.set_linewidth(2) ax.set_xlabel(DataDescription[i]) ax.set_ylabel('Number of Parts') ax.plot([201,201],[0,40],'k--') ax.set_title(PartNum + " -- " + PartDesc) ax.set_xlim([199, 205]) matplotlib.matlab.show() Hope this helps, John Hunter |