我想使用SymLogNorm()
强制我的颜色条的刻度在颜色条上(而不是在它们的值中)等间距,就像它们在默认模式LogNorm()
中一样。如果不手动操作,我怎么能这样做,即不做以下事情:
plt.colorbar(ticks=[vmin, value1, ... , vmax])
我想要的基本上是使用与LogNorm()
(幅度)相同的刻度。以下是我的代码基本上如何工作:
import ...
...
y = np.loadtxt('my_data.dat')
vmin_a = y[0]
vmax_a = y[1]
norm_a = SymLogNorm(linthresh=0.5, linscale=0.03, vmin=vmin_a, vmax=vmax_a)
plt.figure(1)
plt.scatter(x[0], x[1], marker='.', s=7, linewidths=0, c=x[3], cmap= \
plt.get_cmap('RdBu_r'), norm=norm_rs)
plt.xlabel(xax)
plt.ylabel(yax)
plt.colorbar()
pl.xlim([vmin_a, vmax_a])
pl.ylim([vmin_a, vmax_a])
plt.show()
答案 0 :(得分:1)
据我所知,必须使用SymLogNorm手动设置滴答。我通过定义来解决我的问题:
tick_locations_plot=( [vmin]
+ [-(10.0**x) for x in range(minlog-1,-logthresh-1,-1)]
+ [0.0]
+ [(10.0**x) for x in range(-logthresh,maxlog-1)]
+ [vmax] )
,其中
maxlog=int(np.ceil( np.log10(vmax) ))
minlog=int(np.ceil( np.log10(-vmin) ))
然后使用
plt.colorbar(ticks=tick_locations)
做我想要的。