nbinteract icon indicating copy to clipboard operation
nbinteract copied to clipboard

allow passing custom params to plotting functions

Open lukasheinrich opened this issue 6 years ago • 0 comments

currently, the marker settings for each plot type is hard-coded in the function itself.

e.g. for nbi.hist, we see

params = {
        'marks': [{
            'sample': _array_or_placeholder(hist_function),
            'bins': _get_option('bins'),
            'normalized': _get_option('normalized'),
            'scales': (
                lambda opts: {'sample': opts['x_sc'], 'count': opts['y_sc']}
            ),
        }],

which is passed to ._create_marks, then merged with default marks and finally rendered.

It would be nice to be able to control some aspects of the marks, most importantly colors in order to have better control over the rendering

e.g. in order to generate the color-coded stack bar chart in

https://twitter.com/lukasheinrich_/status/1088760129070219266

I needed these params

params = {
        'marks': [{
            'x': _array_or_placeholder(x_fn, PLACEHOLDER_RANGE),
            'y': _array_or_placeholder(y_fn),
            'colors': bq.CATEGORY10,
            'stroke': '#000000'
        }]
    }

since you already have the utility functions to merge param specs (in create_marks) this seems not too difficult to add.

cc @choldgraf

lukasheinrich avatar Jan 25 '19 16:01 lukasheinrich