[英]Pyplot: Cmap(index) -> color function
Suppose I have the following: 假设我有以下内容:
data_mats = [ ... ]
# pseudo code
cmap = plt.(...).get_cmap('magma', low=0, high=len(data_mats))
for i in range(0,len(data_mats)):
# pseudo code
color = cmap(i)
mat = data_mats[i]
plt.plot(mat[:,1],mat[:,2], color=color)
How do I fill in the lines of pseudo code: 如何填写伪代码行:
# lines of pseudo code
cmap = plt.(...).get_cmap('magma', low=0, high=len(data_mats))
color = cmap(i)
Using pyplot? 使用pyplot吗?
(why all the dense examples on matplotlib's website, rather than some code specs?) (为什么所有在matplotlib网站上的密集示例,而不是某些代码规范?)
import matplotlib.pyplot as plt
i = 10
file_ct = 100
cmap = plt.cm.magma
color = cmap(float(i+1) / float(file_ct))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.