added STRUCTURED_RESULT to determine how result should be returned to python, updated plot function to deal with regular arrays