Open welyt opened 1 year ago
bar_label
is only available in the latest version of matplotlib. However, many users are using the lower version of matplotlib. So, it's not supported in PyComplexHeatmap now, which will be considered in the future.
But you can implement it with a few simple lines of code:
# firtly, get the ax from HeatmapAnnotation, for example,
col_ha=HeatmapAnnotation(...)
for ann in col_ha.annotations:
if isinstance(ann,PyComplexHeatmap.annotations.anno_barplot):
# you can get the annotation label using `ann.label`
ann.ax.bar_label(bar_container, fmt='{:,.0f}')
If you are interested, you can contribute by adding bar_label
to the source code if the version of matplotlib >= 3.7 and make a pull request.
If you are interested, you can contribute by adding
bar_label
to the source code if the version of matplotlib >= 3.7 and make a pull request.
Thanks for the invitation. I'll try it when I'm free
the code below works for my case, thank you
for ann in score_anno.values(): if isinstance(ann, ph.annotations.anno_barplot): ann.ax.bar_label(ann.ax.containers[0], fmt='{:,.2f}') ann.ax.set_xlim([1.2,0])
Looks better. I suggest you use parameter orientation='right'
, cause the roataion
of your xlabel
is -90, and the anno_simple
is on the left. Besides, I would suggest you use a smaller figsize
, cause the legend
looks very small.
https://matplotlib.org/stable/users/prev_whats_new/whats_new_3.7.0.html![image](https://user-images.githubusercontent.com/8581547/221808340-e38a3819-ad04-4b34-ba14-b149dabed319.png)