scverse / scverse/scanpy

change location of add_totals values for sc.pl.dotplot

Open
#2,712 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Hi!

I've been playing around with the add_totals method for dotplot.
My general issue is that the labels on the barplots showing the number of cells per group is slightly covered by the barplot/too far to the left.
image

I think this could be fixed by changing ha="center" to ha="left" in the _plot_totals function
https://github.com/scverse/scanpy/blob/ec7f92524e6269e9c7370fc94c53ba04230b0bca/scanpy/plotting/_baseplot_class.py#L481

image
and then possibly moving the axes of the legends further to the right:
image
I'm moving the axis manually, but it would be nice for it to automatically to move the axis, so that it is always a clear visualization.

size_legend_ax = dp.get_axes()["size_legend_ax"]
size_pos = size_legend_ax.get_position()
size_legend_ax.set_position([size_pos.x0 + 0.05, size_pos.y0, size_pos.width, size_pos.height])

color_legend_ax = dp.get_axes()["color_legend_ax"]
color_pos = color_legend_ax.get_position()
color_legend_ax.set_position([color_pos.x0 + 0.05, color_pos.y0 - 0.05, color_pos.width, color_pos.height])

Thanks!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in scanpy/plotting/_baseplot_class.py at _plot_totals, using sc.pl.dotplot with add_totals to reproduce the label overlap. Check how the size_legend_ax and color_legend_ax positions are created and adjusted. Done means totals labels are no longer covered and the legends remain clearly positioned without manual axis movement.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data-visualization
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.