Skip to content
hangfromthefloor edited this page Jul 13, 2011 · 15 revisions

Plotting API (proposed)

1d plotting API

Proposed plan includes simultaneous y-axes (transforms of the coordinate systems)

plottable_data = {
    'type': '1d',
    'title': 'I am the title of the graph',
    'clear_existing': false,
    'xlabel': 'position (m)',
    'ylabel': 'TbFe Intensity (cps)',
    'series': [
        {
            'label': 'File 1',
            'x': [1,2,3,4],
            'y': [1,10,100,1000],
            'color': 'Red',
            'style': 'line',
        },
        {
            'label': 'File 2',
            'x': [1,2,3,4],
            'y': [2,20,200,2000],
            'color': 'Magenta',
            'style': 'line',
        },
    ],
};

nd plotting API

Ability to choose arbitrary axes

plottable_data = {
    'type': 'nd',
    'title': 'I am the title of the graph',
    'clear_existing': false,
    'orderx': ['Q', 'h', 'k', ... ],
    'ordery': ['Intensity', 'SingleDetector', ... ],
    'series': [
        {
            'label': 'File 1',
            'data': {
                'Q': {
                    'label': 'Q',
                    'values': [1, 2, 3, 4],
                    'errors': [1, 2, 3, 4],
                },
                'Intensity': {
                    'label': 'Intensity',
                    'values': [1, 2, 3, 4],
                    'errors': [1, 2, 3, 4],
                },
            },
            'color': 'Red',
            'style': 'line',
        },
    ],
};

2d plotting API

The proposed data structure, to be fed over the wire to the plotting engine, is as follows: in JSON,

plottable_data = {
    'type': '2d',
    'z':  [ [1, 2], [3, 4] ],
    'title': 'This is the title',
    'dims': {
        'xmax': 1.0,
        'xmin': 0.0, 
        'ymin': 0.0, 
        'ymax': 12.0,
        'xdim': 2,
        'ydim': 2,
    },
    'xlabel': 'This is my x-axis label',
    'ylabel': 'This is my y-axis label',
    'zlabel': 'This is my z-axis label',
};

A tool for converting from the industry-standard x,y,z triplets to the row-ordered form above will be provided.

Clone this wiki locally