2
以下のプロット方法はわかりません。私のデータファイルには、次のような構造で多くのtriangularsの隅の点が含まれていますMatPlotLib coulored triangulars
1 0
0 1
1 1
0.1 1
0.2 2
0.3 3
私は1枚の画像にそれらを描き、それぞれ異なる三角形の表面を色付けしたいです。それ、どうやったら出来るの?助けのための
ありがとう:)
以下のプロット方法はわかりません。私のデータファイルには、次のような構造で多くのtriangularsの隅の点が含まれていますMatPlotLib coulored triangulars
1 0
0 1
1 1
0.1 1
0.2 2
0.3 3
私は1枚の画像にそれらを描き、それぞれ異なる三角形の表面を色付けしたいです。それ、どうやったら出来るの?助けのための
ありがとう:)
あなたがポストされたデータの使用artist demo
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.patches as mpatches
fig = plt.figure(figsize=(5,5))
ax = plt.axes([0,0,1,1])
triangle1 = mpatches.Polygon(np.array([[0,1],[1,0],[1,1]]), fc="blue")
triangle2 = mpatches.Polygon(np.array([[-0.1,-1],[-2,-2],[-2,-1]]), fc="red")
ax.add_artist(triangle1)
ax.add_artist(triangle2)
ax.set_xlim(-3, 3)
ax.set_ylim(-3, 3)
plt.show()
で簡単に見:
import matplotlib.pyplot as plt
import matplotlib.patches as patches
import numpy as np
import itertools
fig=plt.figure()
ax=fig.add_subplot(1,1,1)
with open('data') as f:
for points in zip(*[itertools.ifilter(lambda line: line.strip(),f)]*3):
points=([tuple(map(float,p.strip().split())) for p in points])
ax.add_patch(patches.Polygon(points))
ax.autoscale_view()
plt.show()
を