Skip to content
Clifford Bohm edited this page May 17, 2017 · 12 revisions

THIS PAGE IS OUT OF DATE, until it is updated you can see MGraph.py options by running 'python MGraph.py -h'

In order to make graphs you will need to have python and matplotlib (a graphing package for python) installed. You can find guides online to help install both of these. It is advisable to install the latest version of python (version 3.0 or later as apposed to 2).

MGraph.py

MGraph.py is a graphing program that makes graphs from csv files...
While this program will not generate all of the possible graphs that you might need, it provides a way for you to visualize your data with minimal effort. If you run MGraph.py in a directory where you have run MABE, graphs will automatically be generated from the ave.csv and dominant.csv files. These graphs are generated for every column in ave.csv, in addition, the same columns from dominant.csv are also graphed.

python PythonTools/MGraph.py

After a few seconds, you should see images like these...

To quit, either close these images or press <ctrl-c> on the command line and then scroll over one of the images.

mkGraphsFromDefaultRun.py Custom Graphs

MGraph.py can also render custom graphs. For example to create a graph with food1, food2, score and switches graphed against updates:

python PythonTools/MGraph.py -files ave -data food1_AVE food2_AVE score_AVE switches_AVE -combineData -pltStyle randomLine"

MGraph.py -h option

run mkGraphsFromDefaultRun.py with the "-h" option to see all of the options

python PythonTools/MGraph.py -h
usage: MGraph.py [-h] [-path PATH] [-conditions CONDITION [CONDITION ...]]
                 [-conditionNames CONDITION_NAME [CONDITION_NAME ...]]
                 [-files FILE_PREFIX [FILE_PREFIX ...]] [-repRange FIRST LAST]
                 [-repList REP [REP ...]] [-save {pdf,png}]
                 [-data COLUMN_NAME [COLUMN_NAME ...]]
                 [-dataFromFile FILE_NAME] [-xAxis COLUMN_NAME]
                 [-dataIndex COLUMN_NAME]
                 [-pltWhat {ave,error,reps} [{ave,error,reps} ...]]
                 [-pltStyle {line,point,randomLine,randomPoint}]
                 [-errorStyle {region,bar,barX,barXY}] [-numCol #]
                 [-combineConditions] [-combineData] [-verbose]
                 [-legendLocation {ur,ul,lr,ll,cr,cl,lc,uc,c}]
                 [-legendLineWeight LEGENDLINEWEIGHT] [-lineWeight LINEWEIGHT]
                 [-grid] [-fontSizeMajor FONTSIZEMAJOR]
                 [-fontSizeMinor FONTSIZEMINOR] [-fontSizeTicks FONTSIZETICKS]
                 [-whereValue WHEREVALUE]
                 [-whereRange WHERERANGE [WHERERANGE ...]]

optional arguments:
  -h, --help            show this help message and exit
  -path PATH            path to files - default : none (will read files in
                        current directory)
  -conditions CONDITION [CONDITION ...]
                        names of condition directories - default: none (will
                        use files in path directly)
  -conditionNames CONDITION_NAME [CONDITION_NAME ...]
                        names to dispaly. must have same number of elements as
                        conditions if defined - default: none (will use
                        conditionNames)
  -files FILE_PREFIX [FILE_PREFIX ...]
                        file prefex(s) - default: ave dominant
  -repRange FIRST LAST  replicate range - default: none (will use files in
                        path directly)
  -repList REP [REP ...]
                        replicate list. useful if you are missing a replicat.
                        cannot be used with repRange - default: none (will use
                        files in path directly)
  -save {pdf,png}       save files rather then display as either pdf or png -
                        default: none (display image)
  -data COLUMN_NAME [COLUMN_NAME ...]
                        column names of data to be graphed - default : none
                        (will attempt to graph all columns from all files)
  -dataFromFile FILE_NAME
                        this file will be used to determine with column names
                        of data will be graphed. If this file is not in files,
                        then all data will be plotted - default : ave
  -xAxis COLUMN_NAME    column name of data to be used on x axis - default :
                        update
  -dataIndex COLUMN_NAME
                        column name of data to be used as index when
                        generating averages - default : update
  -pltWhat {ave,error,reps} [{ave,error,reps} ...]
                        what should be ploted. ave (averages), error, reps
                        (show data for all reps) - default : ave error
  -pltStyle {line,point,randomLine,randomPoint}
                        plot style. Random is useful if plotting multiple data
                        on the same plot - default : line
  -errorStyle {region,bar,barX,barXY}
                        how error is ploted - default : region
  -numCol #             if ploting a multi plot (default), how many columns in
                        plot - default : 3
  -combineConditions    if ploting multiple conditions, adding this flag will
                        combine data from files with same name - default (if
                        not set) : OFF
  -combineData          if ploting multiple data lines, adding this flag will
                        combine data into one plot - default (if not set) :
                        OFF
  -verbose              adding this flag will provide more text output while
                        running (useful if you are working with a lot of data
                        to make sure that you are not hanging) - default (if
                        not set) : OFF
  -legendLocation {ur,ul,lr,ll,cr,cl,lc,uc,c}
                        if ledgends are needed this is determins placement
                        (first letter u = upper, c = center, l = lower. second
                        letter l = left, c = center, r = right) - default : lr
                        (lower right)
  -legendLineWeight LEGENDLINEWEIGHT
                        changes line thickness in legend - default :
                        lineWeight
  -lineWeight LINEWEIGHT
                        changes line thickness of lines in plots - default : 1
  -grid                 if set, this flag cause a grid to be displayed on
                        plots - default : OFF
  -fontSizeMajor FONTSIZEMAJOR
                        size of "Major" fonts (main title) - default : 15
  -fontSizeMinor FONTSIZEMINOR
                        size of "Minor" fonts (subplot titles and lables) -
                        default : 10
  -fontSizeTicks FONTSIZETICKS
                        size of font for axis ticks - default : 8
  -whereValue WHEREVALUE
                        only plot data where this column has values defined by
                        whereRange - default : update
  -whereRange WHERERANGE [WHERERANGE ...]
                        only plot data where column with name set by
                        whereValue has values defined this range. Single
                        value, just this value. Two values, inclusive range.
                        Three values, inclusive range with step. - default :
                        none
Clone this wiki locally