Example #1
0
"""
This example demonstrates large data sets
"""
from math import *
from odscharts.spreadsheet import SpreadSheet

mySprSht = SpreadSheet()

list_of_rows = [['Angle', 'Sine', 'Cosine'], ['deg', '', '']]
for iang in range(3601):
    ang_deg = float(iang) / 10.0
    ang = radians(ang_deg)

    list_of_rows.append([ang_deg, sin(ang), cos(ang)])

mySprSht.add_sheet('Trig_Data', list_of_rows)

mySprSht.add_scatter('Trig_Plot',
                     'Trig_Data',
                     title='Trig Functions',
                     xlabel='Angle',
                     ylabel='Trig Function',
                     xcol=1,
                     ycolL=[2, 3],
                     showMarkerL=[1, 0])

mySprSht.save(filename='trig_plot', launch=True)
Example #2
0
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'))
Example #3
0
 def setUp(self):
     unittest.TestCase.setUp(self)
     self.mySprSht = SpreadSheet()
Example #4
0
"""
This example demonstrates the proper use of project: odscharts

BMI data from: http://knoema.com/WHOGDOBMIMay/who-global-database-on-body-mass-index-bmi
"""

from odscharts.spreadsheet import SpreadSheet

mySprSht = SpreadSheet()

aussieLL = [['Year', 'Normal Aus', 'Overweight Aus', 'Underweight Aus'],
            ['', '%', '%', '%'], [1990, '', '', ''], [1991, '', '', ''],
            [1992, '', '', ''], [1993, '', '', ''], [1994, '', '', ''],
            [1995, '', 57.3, ''], [1996, '', 57.3, ''], [1999, 39.2, 59.8, 1],
            [2000, 39.2, 59.8, 1], [2001, '', 46.2, ''], [2004, '', 49, ''],
            [2005, '', 49, '']]

mySprSht.add_sheet('Aussie_Data', aussieLL)
mySprSht.add_scatter('Aussie_Plot',
                     'Aussie_Data',
                     title='Australian BMI',
                     xlabel='Year',
                     ylabel='Percent of Population',
                     xcol=1,
                     ycolL=[2, 3, 4])
usaLL = [['Year', 'Normal USA', 'Overweight USA', 'Underweight USA'],
         ['', '%', '%', '%'], [1990, 42.5, 55, 2.5], [1991, 42.5, 55, 2.5],
         [1992, 42.5, 55, 2.5], [1993, 42.5, 55, 2.5], [1994, 42.5, 55, 2.5],
         [1995, 61.9, 36.7, 1.4], [1999, 35.1, 62.5, 2.4],
         [2000, 39.7, 58.3, 2.1], [2001, 35.7, 59.2, 2.4],
         [2002, 35.7, 59.2, 2.4], [2003, '', 54.4, ''], [2004, '', 66.3, ''],
Example #5
0
"""
This example demonstrates the use of line styles
"""
from math import *
from odscharts.spreadsheet import SpreadSheet
from odscharts.line_styles import LINE_STYLE_LIST as sL

mySprSht = SpreadSheet()
rev_orderL = list(range(10, -1, -1))

toprow = ['Line Style Index']
unitsrow = ['']
toprow.extend(['%i) %s' % (i, sL[i]) for i in rev_orderL])
unitsrow.extend(['' for i in rev_orderL])

xbegrow = [0]
xbegrow.extend([i for i in rev_orderL])
xendrow = [1]
xendrow.extend([i for i in rev_orderL])

list_of_rows = [toprow, unitsrow, xbegrow, xendrow]

mySprSht.add_sheet('Line_Style_Data', list_of_rows)

mySprSht.add_scatter('Line_Style',
                     'Line_Style_Data',
                     title='Line Styles',
                     xlabel='',
                     ylabel='Index of Line Style',
                     xcol=1,
                     ycolL=[2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
Example #6
0
"""
This example demonstrates the use of line styles
"""
from math import *
from odscharts.spreadsheet import SpreadSheet
from odscharts.line_styles import LINE_STYLE_LIST as sL

mySprSht = SpreadSheet()
rev_orderL = list( range(10,-1,-1) )

toprow = ['Line Style Index']
unitsrow = ['']
toprow.extend( ['%i) %s'%(i,sL[i]) for i in rev_orderL] )
unitsrow.extend( ['' for i in rev_orderL] )

xbegrow = [0]
xbegrow.extend( [i for i in rev_orderL] )
xendrow = [1]
xendrow.extend( [i for i in rev_orderL] )

list_of_rows = [toprow, unitsrow, xbegrow, xendrow]

mySprSht.add_sheet('Line_Style_Data', list_of_rows)

mySprSht.add_scatter( 'Line_Style', 'Line_Style_Data',
                          title='Line Styles', 
                          xlabel='', 
                          ylabel='Index of Line Style', 
                          xcol=1,
                          ycolL=[2,3,4,5,6,7,8,9,10,11,12], 
                          lineStyleL=[i for i in rev_orderL],
Example #7
0
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)
Example #8
0
"""
This example demonstrates a simple chart
"""
from odscharts.spreadsheet import SpreadSheet

mySprSht = SpreadSheet()

list_of_rows = [
    ["Altitude", "Pressure"],
    ["feet", "psia"],
    [0, 14.7],
    [5000, 12.23],
    [10000, 10.11],
    [30000, 4.36],
    [60000, 1.04],
]

mySprSht.add_sheet("Alt_Data", list_of_rows)

mySprSht.add_scatter(
    "Alt_P_Plot", "Alt_Data", title="Pressure vs Altitude", xlabel="Altitude", ylabel="Pressure", xcol=1, ycolL=[2]
)
mySprSht.save(filename="alt_vs_press")

mySprSht.launch_application()
Example #9
0
    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 )

Example #10
0
"""
This example demonstrates large data sets
"""
from math import *
from odscharts.spreadsheet import SpreadSheet

mySprSht = SpreadSheet()

list_of_rows = [['Angle','Sine','Cosine'], ['deg','','']]
for iang in range( 3601 ):
    ang_deg = float(iang) / 10.0
    ang = radians(ang_deg)
    
    list_of_rows.append( [ang_deg, sin(ang), cos(ang)] )

mySprSht.add_sheet('Trig_Data', list_of_rows)

mySprSht.add_scatter( 'Trig_Plot', 'Trig_Data',
                          title='Trig Functions', 
                          xlabel='Angle', 
                          ylabel='Trig Function', 
                          xcol=1,
                          ycolL=[2,3], showMarkerL=[1,0])
                          
mySprSht.save( filename='trig_plot', launch=True)
Example #11
0
"""
This example demonstrates the proper use of project: odscharts

BMI data from: http://knoema.com/WHOGDOBMIMay/who-global-database-on-body-mass-index-bmi
"""

from odscharts.spreadsheet import SpreadSheet

mySprSht = SpreadSheet()

aussieLL = [
['Year','Normal Aus','Overweight Aus','Underweight Aus'],
['','%','%','%'],
[1990, '', '', ''],
[1991, '', '', ''],
[1992, '', '', ''],
[1993, '', '', ''],
[1994, '', '', ''],
[1995, '', 57.3, ''],
[1996, '', 57.3, ''],
[1999, 39.2, 59.8, 1],
[2000, 39.2, 59.8, 1],
[2001, '', 46.2, ''],
[2004, '', 49, ''],
[2005, '', 49, '']]


mySprSht.add_sheet('Aussie_Data', aussieLL)
mySprSht.add_scatter( 'Aussie_Plot', 'Aussie_Data',
                          title='Australian BMI', xlabel='Year', 
Example #12
0
"""
This example demonstrates a simple chart
"""
from odscharts.spreadsheet import SpreadSheet

mySprSht = SpreadSheet()

list_of_rows = [['Altitude', 'Pressure'], ['feet', 'psia'], [0, 14.7],
                [5000, 12.23], [10000, 10.11], [30000, 4.36], [60000, 1.04]]

mySprSht.add_sheet('Alt_Data', list_of_rows)

mySprSht.add_scatter('Alt_P_Plot',
                     'Alt_Data',
                     title='Pressure vs Altitude',
                     xlabel='Altitude',
                     ylabel='Pressure',
                     xcol=1,
                     ycolL=[2])
mySprSht.save(filename='alt_vs_press')

mySprSht.launch_application()