我想用交替且不重叠的红色和绿色虚线标记函数的一个特定轮廓。我的第一个想法是使用参数化的dash minilanguage,但这会产生一个错误:
import numpy as np
import matplotlib.pyplot as plt
# prepare the data
delta = 0.025
x = np.arange(-1.0, 1.0, delta)
y = np.arange(-1.0, 1.0, delta)
X, Y = np.meshgrid(x, y)
Z1 = np.exp(-(X ** 2) - Y ** 2)
Z2 = np.exp(-((X - 1) ** 2) - (Y - 1) ** 2)
Z = (Z1 - Z2) * 2
# the actual plotting
plt.contour(X, Y, Z, levels=[1.1], linestyles=(0, (5, 5)), colors="red", alpha=0.5)
plt.contour(X, Y, Z, levels=[1.1], linestyles=(5, (5, 5)), colors="green", alpha=0.5)
plt.show()
ValueError: Do not know how to convert [0] to dashes
有什么提示吗
缺少
[]
括号:感谢@JohanC的回复
相关问题 更多 >
编程相关推荐