#๐Ÿ”’ Discrete legend

7 messages ยท Page 1 of 1 (latest)

elder topaz
#

Hello, I am making a heatmap, for each 10% a color is plotted, but I want to make a discrete heatmap instead of a gradiant.

sacred gateBOT
#

@elder topaz

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

elder topaz
#
def discrete_colorbar(cmap, labels, ax=None):
    cmap = plt.cm.get_cmap(cmap, len(labels))
    norm = plt.Normalize(0, len(labels))
    cb = plt.colorbar(plt.cm.ScalarMappable(norm=norm, cmap=cmap), ax=ax, ticks=np.arange(len(labels)) + 0.5)
    cb.set_ticklabels(labels)
    return cb

    labels = ['0%', '10%', '20%', '30%', '40%', '50%', '60%', '70%', '80%', '90%', '100%']
    discrete_colorbar(cmap, labels, ax=ax)```
#

got this, but

#

want this for example

sacred gateBOT
#

@elder topaz

Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.