plotly.py
plotly.py copied to clipboard
pass config options to FigureWidget
Previously I was able to do
plotly.offline.plot(..., config={'showLink':False, 'displayModeBar':False})
Is it possible using the new FigureWidget ?
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 dictconfig = { '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’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 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:
- 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 eitherFigureWidget
-specific, or would work for bothFigureWidget
andFigure
. Note that in general we don't consider theconfig
to be part of the figure, but maybe we could live with something likefig.set_config()
although it might behave a bit oddly: you wouldn't be able to change it once set forFigureWidget
and it would be overridden by the config passed in tofig.show(config=...)
forFigures
. It also wouldn't be stored on disk when written out withfig.write_json()
etc. - Changes to the
plotlywidget
Javascript extension to actually retrieve this info and pass it along to the JS layer
Adding a suggestion. Could you please add the ability to add horizontal and vertical scrollbars to this config?
checking back after a couple of years... any progress on this Issue?
It would be very useful to control the config properties for FigureWidget
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)
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.