Skip to content

How to order the legend #91

Closed Answered by DingWB
WeipengMO asked this question in Q&A
Sep 24, 2024 · 2 comments · 6 replies
Discussion options

You must be logged in to vote

Hi @WeipengMO ,

This is an interesting problem, I have never thought about it.
The order of legends is determined by the variable legend_list, I would suggest you change the order of self.legend_list and plot. For example:
For annotations only:

plt.figure(figsize=(4, 8))
col_ha = HeatmapAnnotation(
            **, plot=False
)
# change the order of legend_list
col_ha.legend_list=[col_ha.legend_list[i] for i in [the target order]]
col_ha.plot_annotations()
plt.show()

Similarly, for ClusterMapPlotter:

plt.figure(figsize=(4, 8))
cm = ClusterMapPlotter(
            **, plot=False
)
# change the order of legend_list
cm.legend_list=[cm.legend_list[i] for i in [the target order]]
cm.plot()
# if …

Replies: 2 comments 6 replies

Comment options

You must be logged in to vote
3 replies
@WeipengMO
Comment options

@WeipengMO
Comment options

@DingWB
Comment options

Answer selected by WeipengMO
Comment options

You must be logged in to vote
3 replies
@WeipengMO
Comment options

@DingWB
Comment options

@WeipengMO
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants