posit-dev / posit-dev/py-shiny
Feature request: enable custom selection of ppi for plots
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.8k
- Forks
- 135
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 21
Description
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?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in shiny/render/_render.py around the global ppi definition and follow how @render.plot passes arguments through to matplotlib savefig() or plotnine/PIL save(). Confirm how a decorator-provided dpi or ppi should update the instance value without creating duplicate arguments, and add coverage showing that custom resolution reaches the plot-saving call.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- matplotlib, python
- Domain
- data-visualization
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100