Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pass config options to FigureWidget #1074

Open
amaurydar opened this issue Jul 26, 2018 · 23 comments
Open

pass config options to FigureWidget #1074

amaurydar opened this issue Jul 26, 2018 · 23 comments
Labels
feature something new P3 backlog

Comments

@amaurydar
Copy link

Previously I was able to do

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

Is it possible using the new FigureWidget ?

@jonmmease
Copy link
Contributor

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
Copy link
Author

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
Copy link

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

@pypeaday
Copy link

Is there an update on using scrollZoom with FigureWidgets yet?

@LukaPitamic
Copy link

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

@emmanuelle
Copy link
Contributor

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
Copy link

@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
Copy link
Contributor

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

@Diogo-Rossi
Copy link

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

@luiztauffer
Copy link

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

@chaffra
Copy link

chaffra commented May 24, 2020

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
Copy link

@mhangaard
Copy link

mhangaard commented May 27, 2020

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
Copy link

@jonmmease Can we expect progress on this anytime soon?

@nicolaskruchten
Copy link
Contributor

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
Copy link

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

@drefrome
Copy link

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
Copy link
Contributor

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
Copy link

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

@luiztauffer
Copy link

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
Copy link

nobane commented Mar 16, 2023

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)

@KertLynx
Copy link

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.

@gvwilson gvwilson self-assigned this Jun 13, 2024
@gvwilson gvwilson removed their assignment Aug 2, 2024
@gvwilson gvwilson added feature something new and removed enhancement labels Aug 12, 2024
@cpsievert
Copy link

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

With the latest releases of plotly and shinywidgets, this workaround should work now posit-dev/py-shinywidgets#173 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature something new P3 backlog
Projects
None yet
Development

No branches or pull requests