Ordering Legends#

To add custom legend to the plot, first define a function that returns the legend object. Then pass it to the custom_legend method.

import numpy as np
import marsilea as ma
from marsilea.plotter import ColorMesh, Colors

data = np.random.randint(0, 10, (10, 10))
from legendkit import cat_legend
def my_legend(): return cat_legend(labels=["my super legend"], colors=["lightblue"], title="My Legend")

h = ma.Heatmap(data, width=3, height=3)
h.custom_legend(my_legend)
h.add_legends()
h.render()
plot custom legend

Total running time of the script: (0 minutes 0.673 seconds)

Gallery generated by Sphinx-Gallery