Matplotlib でグラフプログラミング【Python】at TECH
Matplotlib でグラフプログラミング【Python】 - 暇つぶし2ch222:デフォルトの名無しさん
16/10/10 19:20:25.82 cQ1gLyON.net
>>220 >>221
回答ありがとうございます
参考にして書いて見た結果ボタンを押した位置に応じた場所に点がでるようになりました
度々ですみませんが今度は
1度ボタンを押した後、大きいキャンバスのどこかを2度目のクリックをしたときそこに
1度だけ点がでるようにしたいです
ここからどう変えれば良いでしょうか?(イメージとしてはボタンを押すと,次のクリックの入力待ちになるイメージです

from numpy.random import rand
import matplotlib.pyplot as plt
from matplotlib.widgets import Button
fig = plt.figure()
ax = fig.add_subplot(111)
plt.subplots_adjust(bottom=0.2)
class Index(object):
def __init__(self, ax):
self.ax = ax
def next(self, event):
xdata = event.xdata
ydata = event.ydata
self.ax.plot(xdata, ydata, color="red", marker="o")
plt.draw()
axnext = plt.axes([0.81, 0.05, 0.1, 0.075])
fig.canvas.mpl_connect('button_press_event', Index(ax).next)
bnext = Button(axnext, 'circle')
bnext.on_clicked(Index(ax).next)
plt.show()


次ページ
続きを表示
1を表示
最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch