posit-dev / py-shiny

Shiny for Python
https://shiny.posit.co/py/
MIT License
1.32k stars 82 forks source link

Feature request: enable custom selection of ppi for plots #379

Open AlFontal opened 1 year ago

AlFontal commented 1 year ago

As it stands now, the ppi parameter used to render all kinds of plots is globally defined here: https://github.com/rstudio/py-shiny/blob/59bbe557dc10cdacca43be2895b5e8c627572b75/shiny/render/_render.py#L191-L194

This is later on passed to all subsequent calls until either matplotlib's savefig() or plotnine/PIL's save() methods.

Passing kwargs that end up being passed to those methods with the @render.plot decorator is allowed, but since the previously defined self._ppi is passed as an arg, adding the dpi kwarg with the decorator leads to a multiple values for argument error.

Could it be made so that the self._ppi attribute is updated at instantiation time in cased it is passed as a kwarg and thus allowing more control on figure resolution?

cpsievert commented 1 year ago

Could it be made so that the self._ppi attribute is updated at instantiation time in cased it is passed as a kwarg and thus allowing more control on figure resolution?

Yea, that seems like the right thing to do...a PR would be quite welcome, thanks!