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

Plotting API (proposed)

nd plotting API

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

Mockup of sample nd plot

nd plot

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