spc
spc copied to clipboard
Add get_chart method back to Spc
Present in https://launchpad.net/python-spc/+milestone/0.3:
def get_chart(self, ax=None):
"""Generate chart using matplotlib."""
if not mpl_present:
raise Exception("matplotlib not installed")
if ax == None:
ax = pylab
ax.plot(self._data, "bo-")
ax.plot([0, len(self._data)], [self.center, self.center], "k-")
ax.plot([0, len(self._data)], [self.lcl, self.lcl], "k:")
ax.plot([0, len(self._data)], [self.ucl, self.ucl], "k:")
if self.violating_points.has_key(RULES_7_ON_ONE_SIDE):
for i in self.violating_points[RULES_7_ON_ONE_SIDE]:
ax.plot([i], [self._data[i]], "yo")
if self.violating_points.has_key(RULES_1_BEYOND_3SIGMA):
for i in self.violating_points[RULES_1_BEYOND_3SIGMA]:
ax.plot([i], [self._data[i]], "ro")
pylab.figtext(0.05, 0.04, "Center = %0.3f" % self.center)
# pylab.figtext(0.05, 0.01, "StdDev = %0.3f" % self.sd)
pylab.figtext(0.3, 0.04, "LCL = %0.3f" % self.lcl)
pylab.figtext(0.3, 0.01, "UCL = %0.3f" % self.ucl)
#pylab.show()