Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/358.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用matplotlib中的符号范数在颜色栏上显示等距记号_Python_Matplotlib_Scale_Colorbar - Fatal编程技术网

Python 使用matplotlib中的符号范数在颜色栏上显示等距记号

Python 使用matplotlib中的符号范数在颜色栏上显示等距记号,python,matplotlib,scale,colorbar,Python,Matplotlib,Scale,Colorbar,我希望使用SymLogNorm(),强制我的颜色条的记号在颜色条上等距排列(不在其值中),就像它们在默认模式下的LogNorm()一样。如果不手动操作,我怎么能做到这一点,也就是说,如果不执行以下操作: plt.colorbar(刻度=[vmin,value1,…,vmax]) 我想要的基本上是使用LogNorm()(震级)获得相同的刻度。下面是我的代码的基本工作原理: import ... ... y = np.loadtxt('my_data.dat') vmin_a = y[0] v

我希望使用
SymLogNorm()
,强制我的颜色条的记号在颜色条上等距排列(不在其值中),就像它们在默认模式下的
LogNorm()
一样。如果不手动操作,我怎么能做到这一点,也就是说,如果不执行以下操作:

plt.colorbar(刻度=[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()
我认为下图很好地解释了我不想要它的原因,即它的实际外观: 我感谢你给我的任何暗示。
关于

据我所知,必须使用符号规范手动设置刻度。我通过定义以下内容解决了我的问题:

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] )
在哪里

然后使用

plt.colorbar(ticks=tick_locations)

做我想做的。

什么是
logthresh
?@gauteh这是一个阈值,用于确定绘图的对数与线性。
plt.colorbar(ticks=tick_locations)