Matplotlib: Multiple legends for contour plot for multiple contour variables
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I need to make multiple contours plots of several variables on the same page. I can do this with MATLAB (see below for MATLAB code). I cannot get matplotlib to show multiple legends. Any help would be much appreciated. Python code: import numpy as np from matplotlib import cm as cm from matplotlib import pyplot as plt delta = 0.25 x = np.arange(-3.0, 3.0, delta) y = np.arange(-2.0, 2.0, delta) X, Y = np.meshgrid(x, y) Z1 = X*np.exp(-X**2-Y**2) Z2 = Y*np.exp(-X**2-Y**2) plt.figure() CS = plt.contour(X, Y, Z1, colors='k') plt.clabel(CS, inline