plotly / plotly.py

The interactive graphing library for Python :sparkles: This project now includes Plotly Express!
https://plotly.com/python/
MIT License
16.09k stars 2.54k forks source link

pass config options to FigureWidget #1074

Open amaurydar opened 6 years ago

amaurydar commented 6 years ago

Previously I was able to do

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

Is it possible using the new FigureWidget ?

jonmmease commented 6 years ago

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?

amaurydar commented 6 years ago

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.

LukaPitamic commented 5 years ago

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

pypeaday commented 5 years ago

Is there an update on using scrollZoom with FigureWidgets yet?

LukaPitamic commented 5 years ago

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

emmanuelle commented 4 years ago

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.

LukaPitamic commented 4 years ago

@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.

emmanuelle commented 4 years ago

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

Diogo-Rossi commented 4 years ago

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

luiztauffer commented 4 years ago

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

chaffra commented 4 years ago

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
    }
}
LukaPitamic commented 4 years ago

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

mhangaard commented 4 years ago

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.

jaladh-singhal commented 4 years ago

@jonmmease Can we expect progress on this anytime soon?

nicolaskruchten commented 4 years ago

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!

jaladh-singhal commented 4 years ago

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

drefrome commented 4 years ago

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.

nicolaskruchten commented 4 years ago

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
info-rchitect commented 3 years ago

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

luiztauffer commented 2 years ago

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

nobane commented 1 year ago

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:

vscodesyncsettings commented 9 months ago

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.