Closed mjko1210 closed 4 years ago
I wish that it was straightforward, but matplotlib does not make this easy. Colorbars need to exist in their own axes, so you must either give it a created axis (as done in documentation.ipynb
) or tell it to use space from an existing axis, which can throw off the spacing of the plot.
One thing you could try is to anchor the position of the colorbar to the axes of the data you want to describe. For example, if you want to add a colorbar to a "Purity" axis (like in the documentation), you could use melanoma_comut.axes['Purity'].get_position()
, which would return the exact location of the purity axis in figure coordinates (as bottom left corner, top right corner). You could then use these coordinates to guide where you want to place the colorbar.
Unfortunately, you will still need to manually adjust, and it would be very hard to get this to avoid clashes with other legend elements automatically. It's a difficult problem and something I'm working on.
Thank you for the tips! I was able to make this easier with 'get_position()'.
Hi, For adding tumor purity legend, is there any way to return corresponding position (left, bottom, width, height) without setting it as manually? I found it's really hard to set the right position, I wonder if there is any efficient way to do this.
Thanks!