私は円を保持するfloat x/y配列を持っています。matplotlibとnumpyで画像に円を描く
import matplotlib.pylab as plt
import numpy as np
npX = np.asarray(X)
npY = np.asarray(Y)
plt.imshow(img)
// TO-DO
plt.show()
このセンターを使用して画像に円を表示したいとします。どうすればこれを達成できますか?
私は円を保持するfloat x/y配列を持っています。matplotlibとnumpyで画像に円を描く
import matplotlib.pylab as plt
import numpy as np
npX = np.asarray(X)
npY = np.asarray(Y)
plt.imshow(img)
// TO-DO
plt.show()
このセンターを使用して画像に円を表示したいとします。どうすればこれを達成できますか?
これはmatplotlib.patches.Circle
パッチで実行できます。
例では、XとYの配列をループし、座標ごとに円パッチを作成する必要があります。ここ
は可能重複http://stackoverflow.com/questions(
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.patches import Circle
# Get an example image
import matplotlib.cbook as cbook
image_file = cbook.get_sample_data('grace_hopper.png')
img = plt.imread(image_file)
# Make some example data
x = np.random.rand(5)*img.shape[1]
y = np.random.rand(5)*img.shape[0]
# Create a figure. Equal aspect so circles look circular
fig,ax = plt.subplots(1)
ax.set_aspect('equal')
# Show the image
ax.imshow(img)
# Now, loop through coord arrays, and create a circle at each x,y pair
for xx,yy in zip(x,y):
circ = Circle((xx,yy),50)
ax.add_patch(circ)
# Show the image
plt.show()
(
matplotlib.cbook
から)プロットはpyplot有する円】画像の上に円を配置する例を示します/ 9215658/plot-a-circle-with-pyplot) – kazemakaseあなたは本当ですか?.. – orkan
まあまあです。その質問への答えは、まさにあなたが求めたものである円を描く方法を示しています:) – kazemakase