plotly.py icon indicating copy to clipboard operation
plotly.py copied to clipboard

pass config options to FigureWidget

Open amaurydar opened this issue 6 years ago • 22 comments

Previously I was able to do

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

Is it possible using the new FigureWidget ?

amaurydar avatar Jul 26 '18 18:07 amaurydar

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?

jonmmease avatar Jul 27 '18 10:07 jonmmease

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.

amaurydar avatar Jul 27 '18 14:07 amaurydar

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

LukaPitamic avatar Feb 14 '19 23:02 LukaPitamic

Is there an update on using scrollZoom with FigureWidgets yet?

pypeaday avatar Jul 30 '19 14:07 pypeaday

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

LukaPitamic avatar Jul 31 '19 10:07 LukaPitamic

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.

emmanuelle avatar Jan 10 '20 21:01 emmanuelle

@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 avatar Jan 14 '20 10:01 LukaPitamic

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

emmanuelle avatar Jan 14 '20 13:01 emmanuelle

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

Diogo-Rossi avatar Feb 11 '20 18:02 Diogo-Rossi

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

luiztauffer avatar Apr 02 '20 08:04 luiztauffer

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 avatar May 24 '20 14:05 chaffra

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

LukaPitamic avatar May 24 '20 20:05 LukaPitamic

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.

mhangaard avatar May 27 '20 08:05 mhangaard

@jonmmease Can we expect progress on this anytime soon?

jaladh-singhal avatar Jul 04 '20 11:07 jaladh-singhal

We’re not actively working on this at the moment but we’d certainly accept a community PR if someone wanted to give it a shot!

nicolaskruchten avatar Jul 04 '20 13:07 nicolaskruchten

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

jaladh-singhal avatar Jul 06 '20 13:07 jaladh-singhal

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.

drefrome avatar Jul 24 '20 02:07 drefrome

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

nicolaskruchten avatar Jul 24 '20 13:07 nicolaskruchten

Adding a suggestion. Could you please add the ability to add horizontal and vertical scrollbars to this config?

info-rchitect avatar Apr 22 '21 10:04 info-rchitect

checking back after a couple of years... any progress on this Issue? It would be very useful to control the config properties for FigureWidget

luiztauffer avatar Mar 02 '22 13:03 luiztauffer

It's possible to update the config by assigning the _config property. For example, to hide the modebar:

fig = go.FigureWidget()
fig._config = fig._config | {'displayModeBar': False}
display(fig)

Note:

  • The snippet above requires python 3.9+ to use the | merge operator
  • The _config property must be updated through assignment as stated in this comment. For instance, the following would not work to hide the mode bar:
fig = go.FigureWidget()
fig._config['displayModeBar'] = False
display(fig)

nobane avatar Mar 16 '23 08:03 nobane

It's possible to update the config by assigning the _config property. For example, to hide the modebar:

fig = go.FigureWidget()
fig._config = fig._config | {'displayModeBar': False}
display(fig)

Note:

* The snippet above requires python 3.9+ to use the [`|` merge operator](https://docs.python.org/3/whatsnew/3.9.html#dictionary-merge-update-operators)

* The `_config` property must be updated through assignment [as stated in this comment](https://github.com/plotly/plotly.py/blob/master/packages/python/plotly/plotly/basewidget.py#L43). For instance, the following **would not** work to hide the mode bar:
fig = go.FigureWidget()
fig._config['displayModeBar'] = False
display(fig)

This did not work while creating a plotly plot in Python Shiny. The ModeBar still showed.

vscodesyncsettings avatar Dec 29 '23 07:12 vscodesyncsettings