我想用水平颜色条制作等高线图。酒吧应该有科学记数法的标签。下面的代码一切顺利。但是,现在我想更改指定科学比例的乘数的位置。我认为这被称为轴偏移字符串。有人知道怎么做这个吗?我想将乘法器放在颜色条的右侧(好像它是一个附加标签)。
#http://matplotlib.sourceforge.net/examples/pylab_examples/griddata_demo.html
from numpy.random import uniform, seed
from matplotlib.mlab import griddata
import matplotlib.pyplot as plt
import matplotlib.ticker
import numpy as np
from matplotlib import rcParams
from matplotlib import rc
# make up data.
seed(0)
npts = 200
x = uniform(-2,2,npts)
y = uniform(-2,2,npts)
z = x*np.exp(-x**2-y**2)
# define grid
xi = np.linspace(-2.1,2.1,100)
yi = np.linspace(-2.1,2.1,200)
# grid the data.
zi = griddata(x,y,z,xi,yi,interp='linear')
rcParams['axes.formatter.limits'] = (-1,1)
plt.figure()
CS = plt.contour(xi,yi,zi,25,cmap=plt.cm.jet)
bar = plt.colorbar(orientation='horizontal') # draw colorbar
# plot data points.
plt.xlim(-2,2)
plt.ylim(-2,2)
plt.title('griddata test (%d points)' % npts)
plt.show()