scverse / scanpy

Single-cell analysis in Python. Scales to >1M cells.
https://scanpy.readthedocs.io
BSD 3-Clause "New" or "Revised" License
1.86k stars 595 forks source link

change location of add_totals values for sc.pl.dotplot #2712

Open c-westhoven opened 10 months ago

c-westhoven commented 10 months ago

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!

Zethson commented 10 months ago

Would you be willing to file a PR for this, please?