Plotly.py: pass config options to FigureWidget

Created on 26 Jul 2018  路  18Comments  路  Source: plotly/plotly.py

Previously I was able to do

plotly.offline.plot(..., config={'showLink':False, 'displayModeBar':False})

Is it possible using the new FigureWidget ?

enhancement

Most helpful comment

Yes this would be useful. Really FigureWidget should pass most options available in fig.show(config=config).
One example of config dict

config = {
    'scrollZoom': False,
    'displayModeBar': True,
    'editable': False,
    'showLink':False,
    'displaylogo': False,
    'toImageButtonOptions': {
    'format': 'png', # one of png, svg, jpeg, webp
    'filename': 'custom_image',
    #'height': 500,
    'width': 800,
    'scale': 1, # Multiply title/legend/axis/canvas sizes by this factor
    }
}

Yes. Seconded. The most intuitive for me would be if FigureWidget accepted the exact same config dict.

All 18 comments

Hi @amaurydar , plotly.offline.plot still supports these options as before. But FigureWidget doesn't support them yet.

I'm not certain that we'll be able to support all of the config options in FigureWidget, which of them would you find useful?

Thanks for your reply!

The 2 options I use currently are the ones mentioned above : showLink and displayModeBar.
It looks like by default FigureWidget sets showLink=False, so the only one I need is displayModeBar really.

yup, I'm looking for scrollZoom. If there any work around?

Is there an update on using scrollZoom with FigureWidgets yet?

@nicpayne713 I had to go through ipyevents extension to solve it

Hey @jonmmease I'm also interested in having scrollZoom in a FigureWidget (basically to implement some datashader-like behaviour for level-of-detail visualization of images). Any way I could help you out implementing this? Interested in chatting about this with you.

@jonmmease I got it working, will try to throw everything away which has nothing to do with scrollZoom and upload ipynb to GitHub if you believe it helps you in any way.

@LukaPitamic I'm interested :-). Thanks!

@LukaPitamic @emmanuelle
Could you share this solution? I'm interested too.

Hi all, any progress on this matter? It would be quite useful for many, me included =)

Yes this would be useful. Really FigureWidget should pass most options available in fig.show(config=config).
One example of config dict

config = {
    'scrollZoom': False,
    'displayModeBar': True,
    'editable': False,
    'showLink':False,
    'displaylogo': False,
    'toImageButtonOptions': {
    'format': 'png', # one of png, svg, jpeg, webp
    'filename': 'custom_image',
    #'height': 500,
    'width': 800,
    'scale': 1, # Multiply title/legend/axis/canvas sizes by this factor
    }
}

@chaffra @luiztauffer @Diogo-Rossi @emmanuelle , been promising this for a while, here you go:
https://github.com/LukaPitamic/other/blob/master/Plotly-ScrollZoom.ipynb

Yes this would be useful. Really FigureWidget should pass most options available in fig.show(config=config).
One example of config dict

config = {
    'scrollZoom': False,
    'displayModeBar': True,
    'editable': False,
    'showLink':False,
    'displaylogo': False,
    'toImageButtonOptions': {
    'format': 'png', # one of png, svg, jpeg, webp
    'filename': 'custom_image',
    #'height': 500,
    'width': 800,
    'scale': 1, # Multiply title/legend/axis/canvas sizes by this factor
    }
}

Yes. Seconded. The most intuitive for me would be if FigureWidget accepted the exact same config dict.

@jonmmease Can we expect progress on this anytime soon?

We鈥檙e not actively working on this at the moment but we鈥檇 certainly accept a community PR if someone wanted to give it a shot!

@nicolaskruchten Any pointers where should I look within plolty.py codebase if I want config to work with FigureWidgets?

Adding to the chorus of voices to say that I also need access to the displayModeBar setting for FigureWidget. I've tried hunting down where this is hooked up in the codebase with no luck and would also need some pointers.

Sorry, I never replied to @jaladh-singhal above!

So we would need at least two changes:

  1. A new Python API to provide the config information: FigureWidget doesn't use the .show(config=...) mechanism so that's out. We'd need a proposal for where to put this that is either FigureWidget-specific, or would work for both FigureWidget and Figure. Note that in general we don't consider the config to be part of the figure, but maybe we could live with something like fig.set_config() although it might behave a bit oddly: you wouldn't be able to change it once set for FigureWidget and it would be overridden by the config passed in to fig.show(config=...) for Figures. It also wouldn't be stored on disk when written out with fig.write_json() etc.
  2. Changes to the plotlywidget Javascript extension to actually retrieve this info and pass it along to the JS layer
Was this page helpful?
0 / 5 - 0 ratings