【发布时间】:2020-11-16 11:19:25
【问题描述】:
我正在使用 tkinter 创建一个包含两条曲线的图。我设法绘制了它们,但它仅在 x 轴上显示正值。
graph = Figure(figsize=(5,5), dpi=100)
A0=1
b=.1
y = [-((A0/pi)*(1-b*x))**0.5 for x in range(-101, (int(1/b)+1))]
z = [((A0 / pi) * (1 - b * x)) ** 0.5 for x in range(-101, (int(1/b)+1))]
plot1 = graph.add_subplot(111)
plot2 = graph.add_subplot(111)
plot1.plot(y)
plot2.plot(z)
canvas1 = FigureCanvasTkAgg(graph, master=self)
canvas1.draw()
canvas1.get_tk_widget().grid(row=0, column=0, columnspan=5 )
如何使这些值成为创建曲线期间使用的 x 值?
【问题讨论】:
-
如果您可以将您的代码转换为Minimal, Reproducible Example 将会很有帮助,这是一段我们可以运行而无需编辑它并猜测导入语句是什么的代码。
标签: python-3.x matplotlib tkinter tkinter-canvas