I found the answer in the following post: in the next post .
The solution is that instead of LogFormatter you need to change the function to ScalarFormatter and define \ mhyphen as:
plt.rcParams["text.latex.preamble"].append(r'\mathchardef\mhyphen="2D')
So, the following class definition worked for me:
class Myfmt(mpl.ticker.ScalarFormatter): def __call__(self, x, pos=None):
Then I just changed the line:
cb=plt.colorbar(sc,ax = ax1,aspect=10)
to
cb=plt.colorbar(sc,ax = ax1,aspect=10,format=Myfmt())
and I also included a line to place one exhibitor at the top of the color panel:
cb.formatter.set_powerlimits((0, 0))
Thanks for helping me find the answer!
source share