1

Plotly (python) supports specifying a config like this:

import plotly.express as px

config = {
  'toImageButtonOptions': {
    'format': 'svg', # one of png, svg, jpeg, webp
  }
}

fig = px.bar(x=[1, 2, 3], y=[1, 3, 1])

fig.show(config=config)

My question is: is there a way to set a default value for this?

Maybe I have to create a custom templete and set pio.templates.default?

william_grisaitis
  • 5,170
  • 3
  • 33
  • 40
  • i think that's the only way. (using pio.templates.default) – Amin S Jan 20 '23 at 13:51
  • No, the `config` object is not part of templates. quoted from the doc : _A Template is a graph object that contains two top-level properties: layout and data_. @MattDMo who compulsively closed this post, it has nothing to do with changing the default color palette, which is done via specific `layout` properties, not `config`. – EricLavault Jan 20 '23 at 14:07
  • @EricLavault my bad. Reopened. – MattDMo Jan 20 '23 at 14:12
  • There is a post in the [plotly community](https://community.plotly.com/t/change-default-configuration/15545) that makes a unique template for default configuration information. I have not verified if this approach is still available today. For your information – r-beginners Jan 20 '23 at 14:19
  • thanks for the comments, folks. maybe i have to subclass `PlotlyRenderer` and set the default `config` key-value pair that i want before calling `super(...)` or something? I'm not experienced with subclassing but if someone can sketch a solution this way, i would accept it and be grateful! the implementation of `PlotlyRenderer` is here btw: https://github.com/plotly/plotly.py/blob/179e0d861aabe7ba18e7b6400802dd201f634839/packages/python/plotly/plotly/io/_base_renderers.py#L77 – william_grisaitis Jan 20 '23 at 21:21
  • I just realized my question is a duplicate of https://stackoverflow.com/q/63936983/781938 ... but that question has no answer – william_grisaitis Jan 20 '23 at 21:31

0 Answers0