Open mwe-bixeng opened 4 days ago
Thanks for your feedback, it has already been fixed. You can pass title
to legend_kws
now (you need to re-install from Github).
In addition, you can also pass a dict to HeatmapAnnotation so that the key can contain space, please see example here: https://dingwb.github.io/PyComplexHeatmap/build/html/notebooks/advanced_usage.html#Add-multiple-heatmap-annotations-using-for-loop
Thanks so much for such a quick response! I can confirm that using title in legend_kws works but I think that may have broken the label argument. I added both title and label and get this error:
TypeError: Legend.__init__() got an unexpected keyword argument 'label'
Same as above except I added label
col_ha = HeatmapAnnotation(EnrolGroup=anno_simple(df["Enrolment Group"],add_text=True,legend=True , legend_kws={'color_text':False, 'title': "Enrol Group", 'label':'Enrol Group label'} plot=True,legend=True,legend_gap=3 , legend_order=True , label_side='left' )
Why did you add the parameter label
? There is no such kind of argument label
for legend_kws:
https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.legend.html
I'm following the example link you gave in the previous message (advanced usage)
M1=anno_simple(df_cols['M1'],cmap='jet',legend=lgd,vmax=1,vmin=0,legend_kws={'label':'M1'}),
to change the side label text. the legend title has changed but not the side label. did I misunderstand your instruction?
Oh sorry, I misread which dict you meant. I see what I can do with using a dict into the Heatmap. thanks. But I think the above will still be confusing for others if there is no label directive but it's in the adv usage instructions. cheers
I also added the parameter label
to all annotation functions.
You can re-install the latest version from Github and try this parameter label
.
Excellent! Now I can have 2 different texts for the label and legend. Thank you so much again for such a quick response and fix. Here's an example of where these changes have come in very handy. I used the dict method to change the label text.
col_ha_dict = {"Cancer predisposition": anno_simple(df["Cancer predisposition"] , colors={'Yes': 'purple'} , legend_kws={'color_text':False, 'title': "Identification of a \npreviously unknown \ncancer predisposition"} , add_text=False,legend=True)}
col_ha = HeatmapAnnotation(**col_ha_dict , axis=1 , plot=True,legend=True,legend_gap=3 , label_side='left' )
You don't have to pass a dict to HeatmapAnnotation
, you can set parameter label
with the latest version.
Is there a way to set each row of the annotation with text that has spaces? In my example, I would like the legend title to say "Enrol Group" with a space between the words. And similarly for the label of the row. Or is there a way for title in legend_kws to overwrite the variable value?
I've tried using
legend_kws={'color_text':False, 'title': "Enrol Group"}
in anno_simple but because it's taking the variable name as the title and label, I get this error:TypeError: matplotlib.axes._axes.Axes.legend() got multiple values for keyword argument 'title'
# variable = EnrolGroup which is the title in the legend and label of that row
col_ha = HeatmapAnnotation(EnrolGroup=anno_simple(df["Enrolment Group"],add_text=True,legend=True , legend_kws={'color_text':False, 'title': "Enrol Group"} plot=True,legend=True,legend_gap=3 , legend_order=True , label_side='left' )