[英]Matplotlib Draw Polygons of different color
我想使用fill()
繪制多邊形。 如何繪制不同顏色的多邊形? 在我看來,我只能使用一種顏色。 我嘗試了每個多邊形具有三個顏色值的列表,但length of rgba sequence should be either 3 or 4
出現此錯誤: length of rgba sequence should be either 3 or 4
。 唯一起作用的是具有三個顏色值的數組。 但這導致了相同顏色的多邊形。 為什么像color=np.random.rand(3,num_polygons)
這樣簡單的東西不起作用?
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure()
ax = fig.add_axes([0.,0.,1.,1.])
num_polygons = 2
x = np.random.randn(3,num_polygons)
y = np.random.randn(3,num_polygons)
ax.fill(x,y,color=[0.8,0.3,0.2]) # <--- ??
plt.show()
我錯過了什么?
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure()
ax = fig.add_axes([0.,0.,1.,1.])
num_polygons = 2
x = np.random.randn(3,num_polygons)
y = np.random.randn(3,num_polygons)
ax.fill(x,y, 'green')
plt.show()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.