如何将matplotlib colorbar刻度线更改为面向外?

use*_*472 4 matplotlib colorbar

我在matplotlib示例库中注意到,所有以垂直彩条为特色的图都有朝内的刻度线,

(即从酒吧的边缘进入酒吧的彩色区域).

对于我正在使用的绘图和颜色的类型,将刻度线向外朝向会更好.

我如何从matplotlib库(见下文)修改这个简单的例子,在其颜色条上有朝外的刻度线?

from matplotlib.colors import LogNorm
from pylab import *

#normal distribution center at x=0 and y=5
x = randn(100000)
y = randn(100000)+5

hist2d(x, y, bins=40, norm=LogNorm())
colorbar()
show()
Run Code Online (Sandbox Code Playgroud)

sod*_*odd 8

只需设置tick_params颜色栏:

from matplotlib.colors import LogNorm
from pylab import *

#normal distribution center at x=0 and y=5
x = randn(100000)
y = randn(100000)+5

hist2d(x, y, bins=40, norm=LogNorm())
colorbar().ax.tick_params(axis='y', direction='out')
show()
Run Code Online (Sandbox Code Playgroud)

带有滴答声的Colorbar