1

我希望Tkinter像在中一样显示我的传奇matplotlib

假设我的画布上有这三行:

from Tkinter import Button, Canvas, Tk

root = Tk()

canvas = Canvas()
canvas.grid()

canvas.create_line(0, 0, 20, 20, fill='green', width=2, tags='line1')
canvas.create_line(30, 30, 40, 40, fill='red', width=2, tags='line2')
canvas.create_line(50, 50, 60, 60, fill='blue', width=2,tags='line3')

root.mainloop()

我怎样才能在画布的左下角有一个图例,如下所示:

-------------------------
|   ——————     line1    |
|   ——————     line2    |
|   ——————     line3    |
-------------------------

上面的 ASCII 图例仅用于说明。我真正想要的是一个由内置函数完成的漂亮图例。不过,我不确定它的可行性。

4

2 回答 2

1
于 2013-10-26T07:20:22.420 回答
0

The canvas has no built-in facilities for legends. It is simply a blank canvas on which you can draw lines, polygons, circles and images. You will have to write a function to draw a legend.

于 2013-10-26T13:19:22.657 回答