通过使用matplotlib单击绘制圆

时间:2017-12-17 04:03:08

标签: python matplotlib canvas

我正在尝试根据鼠标点击在一个情节中绘制一个圆。我已经编写了一个代码但是没有点击一个圆圈。

  // works when done in 2 steps!! 
  var weeklyWeather = db.weekRecord
    .Where(x => x.CityId == CityRecord.Id 
      && (x.date >= weekStarting && x.date <= weekEnding))

  // - when combined results are NULL!??
  var weeklyWeather2 = 
    db.weekRecord(x => x.date.Date >= fromDate.Date && x.date.Date <= toDate.Date)
      .ToList();

2 个答案:

答案 0 :(得分:0)

试试这个:

{{1}}

答案 1 :(得分:0)

from matplotlib import pyplot as plt

fig, ax = plt.subplots()
ax.set_xlim([-40, 40])
ax.set_ylim([-40, 40])
ax.set_aspect('equal')

def onclick(event):
    if event.dblclick:
        circle=plt.Circle((event.xdata,event.ydata),2.5,color='black')
        ax.add_patch(circle)
        fig.canvas.draw() #this line was missing earlier
cid = fig.canvas.mpl_connect('button_press_event',onclick)