0
我想知道如何繪製顏色的強度方面使用python。 例如,我有一個列表[0.1,0.5,1.0],我想用1.0圈最暗圓圈,第二個最黑圈圈圈爲0.5,第三個最黑圈圈圈圈爲0.1。顏色matplotlib強度方面
非常感謝您的幫助。
我想知道如何繪製顏色的強度方面使用python。 例如,我有一個列表[0.1,0.5,1.0],我想用1.0圈最暗圓圈,第二個最黑圈圈圈爲0.5,第三個最黑圈圈圈圈爲0.1。顏色matplotlib強度方面
非常感謝您的幫助。
使用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')
看看這個回答你的問題:http://stackoverflow.com/questions/12965075/matplotlib作爲第三變量的函數的散射圖顏色12965761#12965761 –
非常感謝。我通過在matplotlib中使用「plt.cm.Greys」解決了問題。 – Juan