Refactor `BasePlot` not to create a dataframe representation of the data
@dorzhey is already working on this.
Since Jul 29, 2025.
- Dominant language
- Python
- Stars
- 2.6k
- Forks
- 779
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 27
Description
What kind of feature would you like to request?
Additional function parameters / changed functionality / changed defaults?
Please describe your wishes
See #3717 for what prompted me to look at this code.
Currently BasePlot creates a in-memory copy as a dataframe of the main data of interest (obsm, X, layers etc.): https://github.com/scverse/scanpy/blob/0b82c934edeb640095df14e60725ed1fad6eebb1/src/scanpy/plotting/_baseplot_class.py#L148-L157
I believe this to be unnecessary as this dataframe is only ever used for groupby operations, for which we have a zero-copy solution in https://scanpy.readthedocs.io/en/latest/generated/scanpy.get.aggregate.html
Thus we should
- Refactor
Baseplotnot to create a copy - Use the https://scanpy.readthedocs.io/en/latest/generated/scanpy.get.aggregate.html for aggregation
- Ensure this doesn't affect performance
- Integrate #3700
Contributor guide
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.
Assessment
This issue has not been assessed yet.