dataL = [] for bm, mr in zip(body_mass, metabolic_rate): dataL.append([bm, mr]) dataL.sort() # create a list of curve fit data for row in dataL: bm, mr = row row.append(0.022110831039 * bm**0.745374452331) list_of_rows = [['Body Mass', 'Rate Data', 'Fitted Rate'], ['g', 'mLO2/hr', 'mLO2/hr']] list_of_rows.extend(dataL) mySprSht = SpreadSheet() mySprSht.add_sheet('MassRate_Data', list_of_rows) mySprSht.add_scatter('MassRate_Plot', 'MassRate_Data', title='Metabolic Rate vs Body Mass', xlabel='Body Mass', ylabel='Metabolic Rate', xcol=1, logx=1, logy=1, showLineL=[0, 1], showMarkerL=[1, 0], ycolL=[2, 3]) mySprSht.setXrange(xmin=1000) mySprSht.save(filename='mass_vs_rate', launch=True)
class MyTest(unittest.TestCase): def setUp(self): unittest.TestCase.setUp(self) self.mySprSht = SpreadSheet() def tearDown(self): unittest.TestCase.tearDown(self) del (self.mySprSht) def test_should_always_pass_cleanly(self): """Should always pass cleanly.""" pass def test_myclass_existence(self): """Check that myclass exists""" result = self.mySprSht # See if the self.mySprSht object exists self.assertTrue(result) def test_save(self): """Check that save operates cleanly""" list_of_rows = ALT_DATA self.mySprSht.add_sheet('Alt_Data', list_of_rows) self.mySprSht.add_scatter( 'Alt_Plot', 'Alt_Data', title='Unittest Title', xlabel='Unittest X Axis', ylabel='Unittest Y Axis', y2label='Unittest Y2 Axis', xcol=1, ycolL=[2, 3, 4], ycol2L=None, showMarkerL=[1, 1, 1], showMarker2L=None, lineThkL=["0.1in", "0.01in"], lineStyleL=[1, 2, 3], colorL=None, #['cyan','GRaY','#69a'], #['#666666'], labelL=None, label2L=None) self.mySprSht.setXrange(-10000, 70000, plot_sheetname=None) self.mySprSht.setYrange(-100, 700) #self.mySprSht.add_scatter( 'Alt_Plot2', 'Alt_Data') #self.mySprSht.add_scatter( 'Alt_Plot3', 'Alt_Data') self.mySprSht.save(filename=os.path.join(here, 'alt')) def test_save_secondary_y(self): """Check that save operates for a second y axis""" list_of_rows = ALT_DATA_WIDE self.mySprSht.add_sheet('Alt_Data', list_of_rows) self.mySprSht.add_scatter( 'Alt_Plot', 'Alt_Data', title='Unittest Title', xlabel='Unittest X Axis', ylabel='Unittest Y Axis', y2label='Unittest Y2 Axis', xcol=1, ycolL=[2, 5, 6], ycol2L=[3, 4], lineThkL=[1, 2, 3], lineThk2L=[3.5, 1.5], lineStyle2L=[4, 5], showMarkerL=[1, 1, 1], showMarker2L=None, showLineL=[0, 1, 0], showLine2L=[1, 1], #colorL=['r','g','b'], excel_colors=False, color2L=['c','dc'], labelL=None, label2L=None) self.mySprSht.setY2range(50, 550) self.mySprSht.save(filename=os.path.join(here, 'alt_y2')) def test_logx_save(self): """Check that save operates cleanly""" list_of_rows = ALT_DATA self.mySprSht.add_sheet('Alt_Data', list_of_rows) self.mySprSht.add_scatter('Alt_Plot', 'Alt_Data', title='Unittest Title', xlabel='Unittest X Axis', ylabel='Unittest Y Axis', y2label='Unittest Y2 Axis', xcol=1, logx=True, ycolL=[3, 4], ycol2L=None, showMarkerL=[1, 1, 1], showMarker2L=None, colorL=None, labelL=None, label2L=None) self.mySprSht.save(filename=os.path.join(here, 'alt_logx')) def test_logy_save(self): """Check that save operates cleanly""" list_of_rows = ALT_DATA self.mySprSht.add_sheet('Alt_Data', list_of_rows) self.mySprSht.add_scatter('Alt_Plot', 'Alt_Data', title='Unittest Title', xlabel='Unittest X Axis', ylabel='Unittest Y Axis', y2label='Unittest Y2 Axis', xcol=1, logy=True, ycolL=[3, 4], ycol2L=None, showMarkerL=[1, 1, 1], showMarker2L=None, colorL=None, labelL=None, label2L=None) self.mySprSht.save(filename=os.path.join(here, 'alt_logy')) def test_log2y_save(self): """Check that save operates for a second y axis""" list_of_rows = ALT_DATA_WIDE self.mySprSht.add_sheet('Alt_Data', list_of_rows) self.mySprSht.add_scatter('Alt_Plot', 'Alt_Data', title='Unittest Title', xlabel='Unittest X Axis', ylabel='Unittest Y Axis', y2label='Unittest Y2 Axis', xcol=1, log2y=True, ycolL=[2, 5, 6], ycol2L=[3, 4], showMarkerL=[1, 1, 1], showMarker2L=None, colorL=None, labelL=None, label2L=None) self.mySprSht.save(filename=os.path.join(here, 'alt_log2y')) def test_all_log_save(self): """Check that save operates for a second y axis""" list_of_rows = ALT_DATA_WIDE self.mySprSht.add_sheet('Alt_Data', list_of_rows) self.mySprSht.add_scatter('Alt_Plot', 'Alt_Data', title='Unittest Title', xlabel='Unittest X Axis', ylabel='Unittest Y Axis', y2label='Unittest Y2 Axis', xcol=1, log2y=True, logx=True, logy=True, ycolL=[2, 5, 6], ycol2L=[3, 4], showMarkerL=[1, 1, 1], showMarker2L=None, colorL=None, labelL=None, label2L=None) self.mySprSht.save(filename=os.path.join(here, 'alt_all_log'))
148.949, 11.966, 46.414, 123.287, 106.663, 20.619, 180.150, 200.830, 224.779, 148.940, 112.430, 286.847, 46.347, 142.863, 106.670, 119.660, 104.150, 33.165, 4.900, 4.865] dataL = [] for bm, mr in zip(body_mass, metabolic_rate): dataL.append( [bm,mr] ) dataL.sort() # create a list of curve fit data for row in dataL: bm, mr = row row.append( 0.022110831039*bm**0.745374452331 ) list_of_rows = [['Body Mass','Rate Data','Fitted Rate'], ['g','mLO2/hr','mLO2/hr']] list_of_rows.extend( dataL ) mySprSht = SpreadSheet() mySprSht.add_sheet('MassRate_Data', list_of_rows) mySprSht.add_scatter( 'MassRate_Plot', 'MassRate_Data', title='Metabolic Rate vs Body Mass', xlabel='Body Mass', ylabel='Metabolic Rate', xcol=1, logx=1, logy=1, showLineL=[0,1], showMarkerL=[1,0], ycolL=[2,3]) mySprSht.setXrange(xmin=1000) mySprSht.save( filename='mass_vs_rate', launch=True )