The Python classes found in the Pareto.py wrapper file for the ParetoX
plugin. Usage is demonstrated in the Pareto demo profile.
Pareto.py def r2d(response):
'a response string is of the form ID.NAME;Result1=XXX;Result2=YYY'
'ResponseToDict returns a dictionary {Result1:XXX,Result2:YYY}'
items=response.split(';')
d={}
for it in items:
p1=it.find('=')
if p1>-1:
key=it[0:p1]
val=it[p1+1:]
d[key]=val
return d
class TheTitle:
def __init__(self,ax):
self.ax=ax
def Caption(self,value=None):
if value==None:
return r2d(self.ax.GetTitle())['Result']
else:
self.ax.SetTitle('Value=%s' % value)
def Color(self,value=None):
if value==None:
return r2d(self.ax.GetTitleColor())['Result']
else:
self.ax.SetTitleColor('Value=%s' % value)
def FontSize(self,value=None):
if value==None:
return r2d(self.ax.GetTitleFontSize())['Result']
else:
self.ax.SetTitleFontSize('Value=%s' % value)
class TheSubTitle:
def __init__(self,ax):
self.ax=ax
def Caption(self,value=None):
if value==None:
return r2d(self.ax.GetSubTitle())['Result']
else:
self.ax.SetSubTitle('Value=%s' % value)
def Color(self,value=None):
if value==None:
return r2d(self.ax.GetSubTitleColor())['Result']
else:
self.ax.SetSubTitleColor('Value=%s' % value)
def FontSize(self,value=None):
if value==None:
return r2d(self.ax.GetSubTitleFontSize())['Result']
else:
self.ax.SetSubTitleFontSize('Value=%s' % value)
class TheLegend:
def __init__(self,ax):
self.ax=ax
def Show(self,value=None):
if value==None:
return r2d(self.ax.GetShowLegend())['Result']
else:
self.ax.SetShowLegend('Value=%d' % value)
def PanelColor(self,value=None):
if value==None:
return r2d(self.ax.GetLegendPanelColor())['Result']
else:
self.ax.SetLegendPanelColor('Value=%s' % value)
def TextColor(self,value=None):
if value==None:
return r2d(self.ax.GetLegendTextColor())['Result']
else:
self.ax.SetLegendTextColor('Value=%s' % value)
class TheBottomAxis:
def __init__(self,ax):
self.ax=ax
def Caption(self,value=None):
if value==None:
return r2d(self.ax.GetBottomAxisTitle())['Result']
else:
self.ax.SetBottomAxisTitle('Value=%s' % value)
def Color(self,value=None):
if value==None:
return r2d(self.ax.GetBottomAxisTitleColor())['Result']
else:
self.ax.SetBottomAxisTitleColor('Value=%s' % value)
def WallColor(self,value=None):
if value==None:
return r2d(self.ax.GetBottomWallColor())['Result']
else:
self.ax.SetBottomWallColor('Value=%s' % value)
def FontSize(self,value=None):
if value==None:
return r2d(self.ax.GetBottomAxisFontSize())['Result']
else:
self.ax.SetBottomAxisFontSize('Value=%s' % value)
def MarksColor(self,value=None):
if value==None:
return r2d(self.ax.GetXValuesColor())['Result']
else:
self.ax.SetXValuesColor('Value=%s' % value)
class TheLeftAxis:
def __init__(self,ax):
self.ax=ax
def Min(self,value=None):
if value==None:
return r2d(self.ax.GetLeftAxisMin())['Result']
else:
self.ax.SetLeftAxisMin('Value=%f' % value)
def Max(self,value=None):
if value==None:
return r2d(self.ax.GetLeftAxisMax())['Result']
else:
self.ax.SetLeftAxisMax('Value=%f' % value)
def Caption(self,value=None):
if value==None:
return r2d(self.ax.GetLeftAxisTitle())['Result']
else:
self.ax.SetLeftAxisTitle('Value=%s' % value)
def Color(self,value=None):
if value==None:
return r2d(self.ax.GetLeftAxisTitleColor())['Result']
else:
self.ax.SetLeftAxisTitleColor('Value=%s' % value)
def WallColor(self,value=None):
if value==None:
return r2d(self.ax.GetLeftWallColor())['Result']
else:
self.ax.SetLeftWallColor('Value=%s' % value)
def FontSize(self,value=None):
if value==None:
return r2d(self.ax.GetLeftAxisFontSize())['Result']
else:
self.ax.SetLeftAxisFontSize('Value=%s' % value)
def MarksColor(self,value=None):
if value==None:
return r2d(self.ax.GetYValuesColor())['Result']
else:
self.ax.SetYValuesColor('Value=%s' % value)
class Pareto:
def __init__(self,ax):
self.ax=ax
self.LeftAxis = TheLeftAxis(ax)
self.BottomAxis = TheBottomAxis(ax)
self.Title = TheTitle(ax)
self.SubTitle = TheSubTitle(ax)
self.Legend = TheLegend(ax)
def ValuesAsPyDict(self):
return eval(r2d( self.ax.GetValuesAsPyDict())['Result'])
def IsHistogram(self,value=None):
if value==None:
return r2d(self.ax.GetIsHistogram())['Result']
else:
self.ax.SetIsHistogram('Value=%d' % value)
def PanelColor(self,value=None):
if value==None:
return r2d(self.ax.GetPanelColor())['Result']
else:
self.ax.SetPanelColor('Value=%s' % value)
def GetCount(self): return r2d(self.ax.GetCount())['Result']
def GetTotal(self): return r2d(self.ax.GetTotal())['Result']
def SetValue(self,name,value,color):
self.ax.SetValue('Name=%s;Value=%f;Color=%d' % (name,value,color) )
def UpdateColor(self,name,color):
self.ax.UpdateColor('Name=%s;Color=%d' % (name,color))
def UpdateValue(self,name,value):
self.ax.UpdateValue('Name=%s;Value=%f' % (name,value))
def Reset(self): self.ax.Reset()
|