我想改变我标注的内容。我的意思是,而不是水平的值,我想写一些不同的东西。例如,在http://matplotlib.org/examples/pylab_examples/contour_demo.html中的第一个图中,我想改变1.500,1.000,0.5,56%,34%,23%。有可能吗?
答案 0 :(得分:0)
你可以在这些条款上做类似的事情:
import matplotlib
import numpy as np
import matplotlib.cm as cm
import matplotlib.mlab as mlab
import matplotlib.ticker as ticker
import matplotlib.pyplot as plt
matplotlib.rcParams['xtick.direction'] = 'out'
matplotlib.rcParams['ytick.direction'] = 'out'
##################################################
# Define our surface
##################################################
delta = 0.025
x = np.arange(-3.0, 3.0, delta)
y = np.arange(-2.0, 2.0, delta)
X, Y = np.meshgrid(x, y)
Z1 = mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
Z2 = mlab.bivariate_normal(X, Y, 1.5, 0.5, 1, 1)
# difference of Gaussians
Z = 10.0 * (Z2 - Z1)
CS = plt.contour(X, Y, Z)
fmt = {}
strs = [ '54%', '10%', '3%', '47%', '51%', '66%', '7%' ]
for l,s in zip( CS.levels, strs ):
fmt[l] = s
# Label every other level using strings
plt.clabel(CS,CS.levels[::2],inline=True,fmt=fmt,fontsize=10)
plt.show()