我如何对散点图中的颜色进行编码,当变量曲率为0时,将每个点(x,y)着色为黑色,然后曲率越高,颜色越淡为绿色,曲率越负,颜色越淡出为红色?
发布于 2017-09-29 16:32:51
你的问题似乎提出了几个问题。
首先,您必须计算(x,y)数据的曲率。我建议你去看看here。
然后,也许您可以查看matplotlib文档中的所有available colomaps。可能没有必要创建您自己的色彩映射表,尽管这是可能的。
最后,您的代码将类似于:
import numpy as np
import matplotlib.pyplot as plt
x = range(10)
y = np.random.rand(10) # generate random points
curvature = range(10) #compute your curvature here
plt.figure()
plt.scatter(x, y, s=20, c=curvature, cmap=plt.cm.seismic)
#perhaps you want to link points:
plt.plot(x,y)https://stackoverflow.com/questions/45923784
复制相似问题