{"id":1118440,"date":"2025-01-08T18:35:26","date_gmt":"2025-01-08T10:35:26","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1118440.html"},"modified":"2025-01-08T18:35:29","modified_gmt":"2025-01-08T10:35:29","slug":"%e5%a6%82%e4%bd%95%e8%ae%a9python%e4%ba%a7%e7%94%9f%e7%9a%84%e5%9b%be%e5%83%8f%e4%b8%8d%e8%87%aa%e5%8a%a8%e9%80%80%e5%87%ba","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/1118440.html","title":{"rendered":"\u5982\u4f55\u8ba9python\u4ea7\u751f\u7684\u56fe\u50cf\u4e0d\u81ea\u52a8\u9000\u51fa"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25081931\/14a85e1a-544f-4ebe-a1c4-8a8728c4791d.webp\" alt=\"\u5982\u4f55\u8ba9python\u4ea7\u751f\u7684\u56fe\u50cf\u4e0d\u81ea\u52a8\u9000\u51fa\" \/><\/p>\n<p><p> <strong>\u4f7f\u7528<code>matplotlib<\/code>\u7ed8\u5236\u56fe\u50cf\u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7\u8c03\u7528<code>plt.show()<\/code>\u65b9\u6cd5\u6765\u963b\u6b62\u56fe\u50cf\u7a97\u53e3\u81ea\u52a8\u5173\u95ed\u3001\u4f7f\u7528<code>matplotlib<\/code>\u7684\u4ea4\u4e92\u6a21\u5f0f\u3001\u4fdd\u5b58\u56fe\u50cf\u5230\u6587\u4ef6\u4e2d\u4ee5\u4fbf\u540e\u671f\u67e5\u770b\u3001\u4f7f\u7528GUI\u5e93\u6765\u4fdd\u6301\u7a97\u53e3\u6253\u5f00<\/strong>\u3002\u5176\u4e2d\uff0c\u8c03\u7528<code>plt.show()<\/code>\u65b9\u6cd5\u662f\u6700\u5e38\u89c1\u548c\u7b80\u5355\u7684\u65b9\u5f0f\u4e4b\u4e00\u3002 <code>plt.show()<\/code>\u4f1a\u4f7f\u7a0b\u5e8f\u6682\u505c\u5e76\u7b49\u5f85\u7528\u6237\u5173\u95ed\u7a97\u53e3\u540e\u624d\u7ee7\u7eed\u6267\u884c\u3002<\/p>\n<\/p>\n<hr>\n<p><h2>\u4e00\u3001\u8c03\u7528<code>plt.show()<\/code><\/h2>\n<\/p>\n<p><p>\u5728\u4f7f\u7528<code>matplotlib<\/code>\u7ed8\u5236\u56fe\u50cf\u65f6\uff0c\u6700\u5e38\u89c1\u7684\u65b9\u6cd5\u662f\u8c03\u7528<code>plt.show()<\/code>\u6765\u663e\u793a\u56fe\u50cf\u5e76\u963b\u6b62\u7a97\u53e3\u81ea\u52a8\u5173\u95ed\u3002<code>plt.show()<\/code>\u65b9\u6cd5\u5c06\u56fe\u50cf\u663e\u793a\u5728\u7a97\u53e3\u4e2d\uff0c\u5e76\u6682\u505c\u7a0b\u5e8f\u7684\u6267\u884c\uff0c\u76f4\u5230\u7528\u6237\u5173\u95ed\u56fe\u50cf\u7a97\u53e3\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import matplotlib.pyplot as plt<\/p>\n<h2><strong>\u6570\u636e\u51c6\u5907<\/strong><\/h2>\n<p>x = [1, 2, 3, 4, 5]<\/p>\n<p>y = [2, 3, 5, 7, 11]<\/p>\n<h2><strong>\u7ed8\u5236\u56fe\u50cf<\/strong><\/h2>\n<p>plt.plot(x, y)<\/p>\n<h2><strong>\u663e\u793a\u56fe\u50cf<\/strong><\/h2>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u8ff0\u4ee3\u7801\u4e2d\uff0c<code>plt.show()<\/code>\u65b9\u6cd5\u4f1a\u4f7f\u7a0b\u5e8f\u6682\u505c\uff0c\u76f4\u5230\u7528\u6237\u5173\u95ed\u56fe\u50cf\u7a97\u53e3\u3002\u8fd9\u662f\u6700\u7b80\u5355\u548c\u76f4\u63a5\u7684\u65b9\u6cd5\uff0c\u53ef\u4ee5\u786e\u4fdd\u56fe\u50cf\u7a97\u53e3\u4e0d\u81ea\u52a8\u5173\u95ed\u3002<\/p>\n<\/p>\n<p><h2>\u4e8c\u3001\u4f7f\u7528<code>matplotlib<\/code>\u7684\u4ea4\u4e92\u6a21\u5f0f<\/h2>\n<\/p>\n<p><p><code>matplotlib<\/code>\u63d0\u4f9b\u4e86\u4ea4\u4e92\u6a21\u5f0f\uff0c\u5141\u8bb8\u7528\u6237\u5728\u7ed8\u56fe\u7a97\u53e3\u4e0d\u5173\u95ed\u7684\u60c5\u51b5\u4e0b\u7ee7\u7eed\u6267\u884c\u5176\u4ed6\u4ee3\u7801\u3002\u53ef\u4ee5\u901a\u8fc7\u8c03\u7528<code>plt.ion()<\/code>\u65b9\u6cd5\u6765\u5f00\u542f\u4ea4\u4e92\u6a21\u5f0f\uff0c\u5e76\u4f7f\u7528<code>plt.ioff()<\/code>\u65b9\u6cd5\u6765\u5173\u95ed\u4ea4\u4e92\u6a21\u5f0f\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import matplotlib.pyplot as plt<\/p>\n<h2><strong>\u5f00\u542f\u4ea4\u4e92\u6a21\u5f0f<\/strong><\/h2>\n<p>plt.ion()<\/p>\n<h2><strong>\u6570\u636e\u51c6\u5907<\/strong><\/h2>\n<p>x = [1, 2, 3, 4, 5]<\/p>\n<p>y = [2, 3, 5, 7, 11]<\/p>\n<h2><strong>\u7ed8\u5236\u56fe\u50cf<\/strong><\/h2>\n<p>plt.plot(x, y)<\/p>\n<h2><strong>\u663e\u793a\u56fe\u50cf<\/strong><\/h2>\n<p>plt.show()<\/p>\n<h2><strong>\u6267\u884c\u5176\u4ed6\u4ee3\u7801<\/strong><\/h2>\n<p>print(&quot;\u56fe\u50cf\u5df2\u7ecf\u663e\u793a\uff0c\u4f46\u7a0b\u5e8f\u7ee7\u7eed\u8fd0\u884c&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4ea4\u4e92\u6a21\u5f0f\u4e0b\uff0c\u56fe\u50cf\u7a97\u53e3\u4f1a\u4fdd\u6301\u6253\u5f00\uff0c\u7a0b\u5e8f\u53ef\u4ee5\u7ee7\u7eed\u6267\u884c\u5176\u4ed6\u4ee3\u7801\uff0c\u8fd9\u5bf9\u9700\u8981\u52a8\u6001\u66f4\u65b0\u56fe\u50cf\u6216\u5728\u56fe\u50cf\u663e\u793a\u7684\u540c\u65f6\u6267\u884c\u5176\u4ed6\u4efb\u52a1\u975e\u5e38\u6709\u7528\u3002<\/p>\n<\/p>\n<p><h2>\u4e09\u3001\u4fdd\u5b58\u56fe\u50cf\u5230\u6587\u4ef6<\/h2>\n<\/p>\n<p><p>\u6709\u65f6\u4e0d\u9700\u8981\u7acb\u5373\u663e\u793a\u56fe\u50cf\uff0c\u53ea\u9700\u5c06\u5176\u4fdd\u5b58\u5230\u6587\u4ef6\u4e2d\u4f9b\u4ee5\u540e\u67e5\u770b\u3002\u4f7f\u7528<code>plt.savefig()<\/code>\u65b9\u6cd5\u53ef\u4ee5\u5c06\u56fe\u50cf\u4fdd\u5b58\u5230\u6307\u5b9a\u7684\u6587\u4ef6\u4e2d\u3002\u8fd9\u6837\uff0c\u56fe\u50cf\u4e0d\u4f1a\u81ea\u52a8\u5173\u95ed\uff0c\u5e76\u4e14\u53ef\u4ee5\u968f\u65f6\u6253\u5f00\u6587\u4ef6\u67e5\u770b\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import matplotlib.pyplot as plt<\/p>\n<h2><strong>\u6570\u636e\u51c6\u5907<\/strong><\/h2>\n<p>x = [1, 2, 3, 4, 5]<\/p>\n<p>y = [2, 3, 5, 7, 11]<\/p>\n<h2><strong>\u7ed8\u5236\u56fe\u50cf<\/strong><\/h2>\n<p>plt.plot(x, y)<\/p>\n<h2><strong>\u4fdd\u5b58\u56fe\u50cf\u5230\u6587\u4ef6<\/strong><\/h2>\n<p>plt.savefig(&#39;plot.png&#39;)<\/p>\n<p>print(&quot;\u56fe\u50cf\u5df2\u4fdd\u5b58\u5230\u6587\u4ef6&quot;)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4f7f\u7528<code>plt.savefig()<\/code>\u65b9\u6cd5\u53ef\u4ee5\u5c06\u56fe\u50cf\u4fdd\u5b58\u4e3a\u4e0d\u540c\u683c\u5f0f\u7684\u6587\u4ef6\uff08\u5982PNG\u3001JPEG\u3001SVG\u7b49\uff09\uff0c\u5e76\u5728\u9700\u8981\u65f6\u6253\u5f00\u67e5\u770b\u3002<\/p>\n<\/p>\n<p><h2>\u56db\u3001\u4f7f\u7528GUI\u5e93<\/h2>\n<\/p>\n<p><p>\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u53ef\u80fd\u9700\u8981\u4f7f\u7528\u56fe\u5f62\u7528\u6237\u754c\u9762\uff08GUI\uff09\u5e93\u6765\u521b\u5efa\u590d\u6742\u7684\u56fe\u50cf\u663e\u793a\u548c\u4ea4\u4e92\u3002Python\u63d0\u4f9b\u4e86\u591a\u79cdGUI\u5e93\uff0c\u5982Tkinter\u3001PyQt\u3001wxPython\u7b49\uff0c\u5b83\u4eec\u53ef\u4ee5\u4e0e<code>matplotlib<\/code>\u7ed3\u5408\u4f7f\u7528\u6765\u521b\u5efa\u81ea\u5b9a\u4e49\u56fe\u50cf\u7a97\u53e3\u3002<\/p>\n<\/p>\n<p><h3>\u4f7f\u7528Tkinter<\/h3>\n<\/p>\n<p><pre><code class=\"language-python\">import matplotlib.pyplot as plt<\/p>\n<p>from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg<\/p>\n<p>import tkinter as tk<\/p>\n<h2><strong>\u521b\u5efaTkinter\u7a97\u53e3<\/strong><\/h2>\n<p>root = tk.Tk()<\/p>\n<p>root.title(&quot;Matplotlib\u56fe\u50cf&quot;)<\/p>\n<h2><strong>\u6570\u636e\u51c6\u5907<\/strong><\/h2>\n<p>x = [1, 2, 3, 4, 5]<\/p>\n<p>y = [2, 3, 5, 7, 11]<\/p>\n<h2><strong>\u521b\u5efa\u56fe\u50cf<\/strong><\/h2>\n<p>fig, ax = plt.subplots()<\/p>\n<p>ax.plot(x, y)<\/p>\n<h2><strong>\u5c06\u56fe\u50cf\u5d4c\u5165Tkinter\u7a97\u53e3<\/strong><\/h2>\n<p>canvas = FigureCanvasTkAgg(fig, master=root)<\/p>\n<p>canvas.draw()<\/p>\n<p>canvas.get_tk_widget().pack()<\/p>\n<h2><strong>\u8fd0\u884cTkinter\u4e8b\u4ef6\u5faa\u73af<\/strong><\/h2>\n<p>root.m<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>nloop()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4e0a\u8ff0\u4ee3\u7801\u4e2d\uff0c\u4f7f\u7528Tkinter\u521b\u5efa\u4e86\u4e00\u4e2a\u7a97\u53e3\uff0c\u5e76\u5c06<code>matplotlib<\/code>\u56fe\u50cf\u5d4c\u5165\u5176\u4e2d\u3002\u7a97\u53e3\u4f1a\u4fdd\u6301\u6253\u5f00\uff0c\u76f4\u5230\u7528\u6237\u5173\u95ed\u5b83\u3002<\/p>\n<\/p>\n<p><h3>\u4f7f\u7528PyQt<\/h3>\n<\/p>\n<p><pre><code class=\"language-python\">import sys<\/p>\n<p>import matplotlib.pyplot as plt<\/p>\n<p>from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas<\/p>\n<p>from PyQt5.QtWidgets import QApplication, QMainWindow<\/p>\n<p>class MatplotlibWidget(QMainWindow):<\/p>\n<p>    def __init__(self):<\/p>\n<p>        super().__init__()<\/p>\n<p>        # \u521b\u5efa\u56fe\u50cf<\/p>\n<p>        self.figure, self.ax = plt.subplots()<\/p>\n<p>        self.ax.plot([1, 2, 3, 4, 5], [2, 3, 5, 7, 11])<\/p>\n<p>        # \u5c06\u56fe\u50cf\u5d4c\u5165PyQt\u7a97\u53e3<\/p>\n<p>        self.canvas = FigureCanvas(self.figure)<\/p>\n<p>        self.setCentralWidget(self.canvas)<\/p>\n<p>if __name__ == &quot;__main__&quot;:<\/p>\n<p>    app = QApplication(sys.argv)<\/p>\n<p>    # \u521b\u5efa\u5e76\u663e\u793a\u7a97\u53e3<\/p>\n<p>    window = MatplotlibWidget()<\/p>\n<p>    window.show()<\/p>\n<p>    # \u8fd0\u884cPyQt\u4e8b\u4ef6\u5faa\u73af<\/p>\n<p>    sys.exit(app.exec_())<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u8ff0\u4ee3\u7801\u4e2d\uff0c\u4f7f\u7528PyQt\u521b\u5efa\u4e86\u4e00\u4e2a\u7a97\u53e3\uff0c\u5e76\u5c06<code>matplotlib<\/code>\u56fe\u50cf\u5d4c\u5165\u5176\u4e2d\u3002\u7a97\u53e3\u4f1a\u4fdd\u6301\u6253\u5f00\uff0c\u76f4\u5230\u7528\u6237\u5173\u95ed\u5b83\u3002<\/p>\n<\/p>\n<p><h2>\u4e94\u3001\u7ed3\u5408\u591a\u79cd\u65b9\u6cd5<\/h2>\n<\/p>\n<p><p>\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u53ef\u4ee5\u7ed3\u5408\u591a\u79cd\u65b9\u6cd5\u6765\u6ee1\u8db3\u5177\u4f53\u9700\u6c42\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u5728\u4ea4\u4e92\u6a21\u5f0f\u4e0b\u7ed8\u5236\u56fe\u50cf\uff0c\u540c\u65f6\u4fdd\u5b58\u56fe\u50cf\u5230\u6587\u4ef6\uff0c\u6216\u4f7f\u7528GUI\u5e93\u521b\u5efa\u81ea\u5b9a\u4e49\u56fe\u50cf\u7a97\u53e3\uff0c\u5e76\u7ed3\u5408\u4ea4\u4e92\u6a21\u5f0f\u52a8\u6001\u66f4\u65b0\u56fe\u50cf\u3002<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import matplotlib.pyplot as plt<\/p>\n<p>import numpy as np<\/p>\n<p>from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg<\/p>\n<p>import tkinter as tk<\/p>\n<h2><strong>\u521b\u5efaTkinter\u7a97\u53e3<\/strong><\/h2>\n<p>root = tk.Tk()<\/p>\n<p>root.title(&quot;\u5b9e\u65f6\u66f4\u65b0\u7684Matplotlib\u56fe\u50cf&quot;)<\/p>\n<h2><strong>\u521d\u59cb\u5316\u6570\u636e<\/strong><\/h2>\n<p>x = np.linspace(0, 2 * np.pi, 100)<\/p>\n<p>y = np.sin(x)<\/p>\n<h2><strong>\u521b\u5efa\u56fe\u50cf<\/strong><\/h2>\n<p>fig, ax = plt.subplots()<\/p>\n<p>line, = ax.plot(x, y)<\/p>\n<h2><strong>\u5c06\u56fe\u50cf\u5d4c\u5165Tkinter\u7a97\u53e3<\/strong><\/h2>\n<p>canvas = FigureCanvasTkAgg(fig, master=root)<\/p>\n<p>canvas.draw()<\/p>\n<p>canvas.get_tk_widget().pack()<\/p>\n<h2><strong>\u66f4\u65b0\u56fe\u50cf\u7684\u51fd\u6570<\/strong><\/h2>\n<p>def update_plot():<\/p>\n<p>    y_new = np.sin(x + update_plot.counter)<\/p>\n<p>    line.set_ydata(y_new)<\/p>\n<p>    canvas.draw()<\/p>\n<p>    update_plot.counter += 0.1<\/p>\n<p>    root.after(100, update_plot)<\/p>\n<p>update_plot.counter = 0<\/p>\n<h2><strong>\u8fd0\u884cTkinter\u4e8b\u4ef6\u5faa\u73af<\/strong><\/h2>\n<p>root.after(100, update_plot)<\/p>\n<p>root.mainloop()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5728\u4e0a\u8ff0\u4ee3\u7801\u4e2d\uff0c\u4f7f\u7528Tkinter\u521b\u5efa\u4e86\u4e00\u4e2a\u7a97\u53e3\uff0c\u5e76\u5c06<code>matplotlib<\/code>\u56fe\u50cf\u5d4c\u5165\u5176\u4e2d\u3002\u901a\u8fc7\u5b9a\u65f6\u8c03\u7528<code>update_plot<\/code>\u51fd\u6570\uff0c\u56fe\u50cf\u4f1a\u5b9e\u65f6\u66f4\u65b0\uff0c\u7a97\u53e3\u4f1a\u4fdd\u6301\u6253\u5f00\uff0c\u76f4\u5230\u7528\u6237\u5173\u95ed\u5b83\u3002<\/p>\n<\/p>\n<hr>\n<p><p>\u901a\u8fc7\u672c\u6587\u7684\u4ecb\u7ecd\uff0c\u53ef\u4ee5\u5b66\u4e60\u5230\u5982\u4f55\u8ba9Python\u4ea7\u751f\u7684\u56fe\u50cf\u4e0d\u81ea\u52a8\u9000\u51fa\u7684\u591a\u79cd\u65b9\u6cd5\u3002\u6839\u636e\u5177\u4f53\u9700\u6c42\uff0c\u53ef\u4ee5\u9009\u62e9\u5408\u9002\u7684\u65b9\u6cd5\uff0c\u6216\u7ed3\u5408\u591a\u79cd\u65b9\u6cd5\u6765\u6ee1\u8db3\u5b9e\u9645\u5e94\u7528\u3002\u65e0\u8bba\u662f\u7b80\u5355\u7684<code>plt.show()<\/code>\u65b9\u6cd5\uff0c\u8fd8\u662f\u590d\u6742\u7684GUI\u5e93\u7ed3\u5408\u4ea4\u4e92\u6a21\u5f0f\uff0c\u90fd\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u5728Python\u4e2d\u9ad8\u6548\u5730\u7ed8\u5236\u548c\u663e\u793a\u56fe\u50cf\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728\u4f7f\u7528Python\u751f\u6210\u56fe\u50cf\u65f6\u4fdd\u6301\u7a97\u53e3\u6253\u5f00\uff1f<\/strong><br \/>\u5728Python\u4e2d\u4f7f\u7528Matplotlib\u6216\u5176\u4ed6\u56fe\u5f62\u5e93\u751f\u6210\u56fe\u50cf\u65f6\uff0c\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u56fe\u50cf\u7a97\u53e3\u53ef\u80fd\u4f1a\u5728\u663e\u793a\u540e\u7acb\u5373\u5173\u95ed\u3002\u4e3a\u4e86\u4fdd\u6301\u7a97\u53e3\u6253\u5f00\uff0c\u53ef\u4ee5\u4f7f\u7528<code>plt.show()<\/code>\u547d\u4ee4\u3002\u786e\u4fdd\u5728\u751f\u6210\u56fe\u50cf\u540e\u8c03\u7528\u6b64\u547d\u4ee4\uff0c\u5b83\u4f1a\u963b\u6b62\u7a0b\u5e8f\u7ee7\u7eed\u6267\u884c\uff0c\u76f4\u5230\u7528\u6237\u5173\u95ed\u56fe\u50cf\u7a97\u53e3\u3002<\/p>\n<p><strong>\u6709\u6ca1\u6709\u65b9\u6cd5\u53ef\u4ee5\u5728\u56fe\u50cf\u663e\u793a\u540e\u6dfb\u52a0\u4ea4\u4e92\u529f\u80fd\uff1f<\/strong><br \/>\u786e\u5b9e\u53ef\u4ee5\uff01\u4f7f\u7528Matplotlib\uff0c\u4f60\u53ef\u4ee5\u6dfb\u52a0\u4ea4\u4e92\u529f\u80fd\uff0c\u6bd4\u5982\u7f29\u653e\u548c\u5e73\u79fb\u3002\u901a\u8fc7\u4f7f\u7528<code>%matplotlib notebook<\/code>\u6216<code>%matplotlib qt<\/code>\u547d\u4ee4\uff0c\u53ef\u4ee5\u5b9e\u73b0\u66f4\u597d\u7684\u4ea4\u4e92\u4f53\u9a8c\u3002\u6b64\u5916\uff0c\u8fd8\u53ef\u4ee5\u6dfb\u52a0\u4e8b\u4ef6\u5904\u7406\u51fd\u6570\uff0c\u4ee5\u4fbf\u5728\u7528\u6237\u4e0e\u56fe\u50cf\u8fdb\u884c\u4ea4\u4e92\u65f6\u6267\u884c\u7279\u5b9a\u64cd\u4f5c\u3002<\/p>\n<p><strong>\u5982\u4f55\u5728\u56fe\u50cf\u7a97\u53e3\u4e2d\u6dfb\u52a0\u63a7\u4ef6\u6216\u6309\u94ae\uff1f<\/strong><br \/>\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528Matplotlib\u7684<code>widgets<\/code>\u6a21\u5757\u6765\u6dfb\u52a0\u63a7\u4ef6\uff0c\u4f8b\u5982\u6309\u94ae\u3001\u6ed1\u5757\u6216\u590d\u9009\u6846\u3002\u8fd9\u4e9b\u63a7\u4ef6\u53ef\u4ee5\u5e2e\u52a9\u7528\u6237\u4e0e\u56fe\u50cf\u8fdb\u884c\u66f4\u590d\u6742\u7684\u4ea4\u4e92\u3002\u53ea\u9700\u5bfc\u5165<code>from matplotlib.widgets import Button<\/code>\u7b49\u6a21\u5757\uff0c\u5e76\u5728\u56fe\u50cf\u4e2d\u6307\u5b9a\u63a7\u4ef6\u7684\u4f4d\u7f6e\u548c\u529f\u80fd\u5373\u53ef\u521b\u5efa\u4ea4\u4e92\u5f0f\u56fe\u5f62\u5e94\u7528\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u4f7f\u7528matplotlib\u7ed8\u5236\u56fe\u50cf\u65f6\uff0c\u53ef\u4ee5\u901a\u8fc7\u8c03\u7528plt.show()\u65b9\u6cd5\u6765\u963b\u6b62\u56fe\u50cf\u7a97\u53e3\u81ea\u52a8\u5173\u95ed\u3001\u4f7f\u7528matpl [&hellip;]","protected":false},"author":3,"featured_media":1118453,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1118440"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=1118440"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1118440\/revisions"}],"predecessor-version":[{"id":1118456,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1118440\/revisions\/1118456"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1118453"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1118440"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1118440"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1118440"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}