2015-10-28 123 views
0

我想知道如何绘制颜色的强度方面使用python。 例如,我有一个列表[0.1,0.5,1.0],我想用1.0圈最暗圆圈,第二个最黑圈圈圈为0.5,第三个最黑圈圈圈圈为0.1。颜色matplotlib强度方面

非常感谢您的帮助。

+0

看看这个回答你的问题:http://stackoverflow.com/questions/12965075/matplotlib作为第三变量的函数的散射图颜色12965761#12965761 –

+0

非常感谢。我通过在matplotlib中使用“plt.cm.Greys”解决了问题。 – Juan

回答

1

使用matplotlib,你可以做这样的事情:

from __future__ import division 
from matplotlib import pyplot as plt 
import numpy as np 

plt.ion() 

centers = [0.1, 0.5, 1.0] 
radii = [0.1, 0.2, 0.3] 
num_circs = len(centers) 

# make plot 
fig, ax = plt.subplots(figsize=(6, 6)) 
red = np.linspace(0, 1, num_circs) 
green = 0. * red 
blue = 1. - red 
colors = np.array([red, green, blue]).T 
power = 1.5 # adjust this upward to make brightness fall off faster 
for ii, (center_x, radius) in enumerate(zip(centers, radii)): 
    color = colors[ii] 
    brightness = ((num_circs-ii)/num_circs)**power # low ii is brighter 
    color = color * brightness 
    circle = plt.Circle((center_x, 0.), radius, color=color) 
    ax.add_artist(circle) 
_ = plt.axis([-0.3, 1.5, -0.9, 0.9], 'equal') 
plt.savefig('circles.png') 

产生这样的: circles.png