2016-10-31 6 views
0

私が持っている:ダークボーダーで透明なフェーカラーのポリゴンを描画するにはどうすればよいですか? matplotlibので

cmap = plt.cm.RdYlBu_r 
colors = cmap(np.linspace(0,1, len(patches))) 
collection = PatchCollection(patches, alpha=.3, 
          facecolor=colors, linestyle='solid') 

をし、それは私が国境は「アルファ」属性を継承することを除いて欲しいものを私に与えます。濃い枠線ではなく透過的な枠線でポリゴンを描画するにはどうすればよいですか?あなたのポリゴンを構成するポイントを維持し、次のコードのようにポイントを結ぶ線を描画できバイパスソリューションとして

答えて

0

import matplotlib 
import numpy,matplotlib.pyplot as plt 
from matplotlib.patches import Polygon 
from matplotlib.collections import PatchCollection 
fig = plt.figure() 
axe = fig.add_subplot(111) 
polyval = numpy.random.rand(4,2) # Create the sequence of 4 2D points 
patches = [Polygon(polyval,True)] 
p = PatchCollection(patches,cmap=matplotlib.cm.jet,alpha=0.3) 
p.set_array(100.*numpy.random.rand(1)) # Set a random color on jet map 
axe.add_collection(p) 
fig.colorbar(p) 
fig.show() 
for patch in patches: 
    axe.add_patch(Polygon(patch.get_xy(),closed=True,ec='k',lw=3,fill=False)) #draw the contours 
fig.canvas.draw() 
関連する問題