Matplotlib colorbar ticks on left/opposite side

前端 未结 4 1895
孤城傲影
孤城傲影 2020-12-09 08:31

One could generate a vertical colorbar like so(simplified):

import matplotlib.pyplot as plt
import matplotlib as mpl

plt.figure()
c_ax=plt.subplot(111)
cb =          


        
4条回答
  •  旧时难觅i
    2020-12-09 09:17

    I don't know why, but none of these commands worked for me. If that's also your case, I solved the issue by specifying the colorbar property

    location='left'
    

    which takes care of both the ticks and the label. If you still want the colorbar to be on the right side of the plot, just define a new axis limited to the position you want and link you colorbar to it.

    cbar_ax=fig.add_axes([x0, y0, width, height])
    

提交回复
热议问题