pythonmatplotlibunicodesubscript

Subscript unicode character symbol in Python


I would like to use a subscript infinity symbol (u221e) within a colour bar label in Python, like this.

The following line of code allows me to do this partially, but without the subscript:

label="U/U"+u"\u221e"
cb=cbar.ColorbarBase(cax,cmap=colourmap,norm=normalisecolors,orientation='horizontal',label=label)

I would be grateful for any advice on how this line could be modified to subscript the unicode character symbol.


Solution

  • I eventually resolved this through trial and error. To correctly display the subscript unicode character symbol in the colour bar label, I changed the label string as follows:

    label="$U/U_{"+(u"\u221e")+"}$"
    cb=cbar.ColorbarBase(cax,cmap=colourmap,norm=normalisecolors,orientation='horizontal',label=label)
    

    The resulting colour bar label: Colour bar