documentation在这里有点神秘.
surfacecolor
(list, numpy array, or Pandas series of numbers, strings, or datetimes.)
Sets the surface color values, used for setting a color scale independent of z.
我从来没有设法列出字符串,即颜色值,如’rgb(0.3,0.5,0)’或RGB元组.
但您可以使用所需的颜色定义自己的色标.
colorscale = [[0, 'rgb' + str(cmap(1)[0:3])],
[1, 'rgb' + str(cmap(2)[0:3])]]
然后提供与绘制值具有相同尺寸的数值数组.
colors_saddle = np.zeros(shape=saddle.shape)
所有值都设置为0,因此将映射到色阶中的第一种颜色.对于下一种颜色也是如此.
此外,您需要手动设置cmax和cmin.
完整的代码
import numpy as np
import matplotlib.pyplot as plt
import plotly.graph_objs as go
import plotly.offline as off
off.init_notebook_mode()
make_int = np.vectorize(int)
cmap = plt.get_cmap("tab10")
saddle = np.array([[x**2-y**2 for x in np.arange(-10,11)] for y in np.arang