{"id":946499,"date":"2024-12-26T23:42:52","date_gmt":"2024-12-26T15:42:52","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/946499.html"},"modified":"2024-12-26T23:42:54","modified_gmt":"2024-12-26T15:42:54","slug":"python%e5%a6%82%e4%bd%95%e5%ae%89%e8%a3%85matplotlib","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/946499.html","title":{"rendered":"python\u5982\u4f55\u5b89\u88c5matplotlib"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/25082639\/e21718fe-6d32-428c-9dbd-6436a154bde7.webp\" alt=\"python\u5982\u4f55\u5b89\u88c5matplotlib\" \/><\/p>\n<p><p> <strong>\u5728Python\u4e2d\u5b89\u88c5matplotlib\u901a\u5e38\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u65b9\u6cd5\u5b9e\u73b0\uff1a\u4f7f\u7528pip\u547d\u4ee4\u3001\u901a\u8fc7Anaconda\u5b89\u88c5\u3001\u4ece\u6e90\u7801\u5b89\u88c5\u3002<\/strong> \u9996\u5148\uff0c\u6700\u5e38\u89c1\u4e14\u6700\u7b80\u5355\u7684\u65b9\u6cd5\u662f\u4f7f\u7528pip\u547d\u4ee4\uff0c\u6267\u884c<code>pip install matplotlib<\/code>\u5373\u53ef\u5b8c\u6210\u5b89\u88c5\u3002\u5176\u6b21\uff0c\u5982\u679c\u4f60\u4f7f\u7528\u7684\u662fAnaconda\uff0c\u53ef\u4ee5\u901a\u8fc7<code>conda install matplotlib<\/code>\u8fdb\u884c\u5b89\u88c5\u3002\u6700\u540e\uff0c\u5bf9\u4e8e\u9ad8\u7ea7\u7528\u6237\u6216\u6709\u7279\u6b8a\u9700\u6c42\u7684\u7528\u6237\uff0c\u53ef\u4ee5\u9009\u62e9\u4ece\u6e90\u7801\u5b89\u88c5\uff0c\u8fd9\u9700\u8981\u4ecematplotlib\u7684\u5b98\u7f51\u4e0a\u4e0b\u8f7d\u6e90\u7801\uff0c\u5e76\u624b\u52a8\u8fdb\u884c\u7f16\u8bd1\u548c\u5b89\u88c5\u3002\u4e0b\u9762\u5c06\u8be6\u7ec6\u63cf\u8ff0\u5982\u4f55\u901a\u8fc7pip\u547d\u4ee4\u8fdb\u884c\u5b89\u88c5\u3002<\/p>\n<\/p>\n<p><p>\u4f7f\u7528pip\u547d\u4ee4\u5b89\u88c5matplotlib\u975e\u5e38\u7b80\u5355\uff0c\u53ea\u9700\u6253\u5f00\u547d\u4ee4\u884c\u6216\u7ec8\u7aef\u7a97\u53e3\uff0c\u7136\u540e\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install matplotlib<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u4e2a\u547d\u4ee4\u5c06\u81ea\u52a8\u4ecePython\u7684\u5b98\u65b9\u8f6f\u4ef6\u5305\u5b58\u50a8\u5e93PyPI\u4e2d\u4e0b\u8f7d\u5e76\u5b89\u88c5matplotlib\u53ca\u5176\u6240\u6709\u4f9d\u8d56\u5305\u3002pip\u662f\u4e00\u79cdPython\u5305\u7ba1\u7406\u5de5\u5177\uff0c\u5b83\u80fd\u591f\u81ea\u52a8\u5904\u7406\u4f9d\u8d56\u5173\u7cfb\uff0c\u4f7f\u5f97\u5b89\u88c5\u8fc7\u7a0b\u975e\u5e38\u65b9\u4fbf\u3002<\/p>\n<\/p>\n<p><p>\u4e00\u3001PIP\u5b89\u88c5MATPLOTLIB<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u68c0\u67e5Python\u73af\u5883<\/strong><\/p>\n<\/p>\n<p><p>\u5728\u5b89\u88c5matplotlib\u4e4b\u524d\uff0c\u786e\u4fdd\u4f60\u5df2\u7ecf\u5b89\u88c5\u4e86Python\u548cpip\u3002\u53ef\u4ee5\u901a\u8fc7\u5728\u547d\u4ee4\u884c\u4e2d\u8f93\u5165<code>python --version<\/code>\u548c<code>pip --version<\/code>\u6765\u68c0\u67e5\u5b83\u4eec\u662f\u5426\u5df2\u7ecf\u5b89\u88c5\u4ee5\u53ca\u7248\u672c\u4fe1\u606f\u3002\u5982\u679c\u6ca1\u6709\u5b89\u88c5Python\uff0c\u53ef\u4ee5\u524d\u5f80Python\u5b98\u65b9\u7f51\u7ad9\u4e0b\u8f7d\u5e76\u5b89\u88c5\u76f8\u5e94\u7248\u672c\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4f7f\u7528PIP\u5b89\u88c5MATPLOTLIB<\/strong><\/p>\n<\/p>\n<p><p>\u6253\u5f00\u547d\u4ee4\u884c\u6216\u7ec8\u7aef\u7a97\u53e3\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\u8fdb\u884c\u5b89\u88c5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install matplotlib<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8be5\u547d\u4ee4\u5c06\u81ea\u52a8\u4ecePyPI\u4e2d\u4e0b\u8f7dmatplotlib\u5e93\u7684\u6700\u65b0\u7248\u672c\u53ca\u5176\u4f9d\u8d56\u9879\uff0c\u5e76\u8fdb\u884c\u5b89\u88c5\u3002\u6574\u4e2a\u8fc7\u7a0b\u6839\u636e\u7f51\u7edc\u901f\u5ea6\u53ca\u8ba1\u7b97\u673a\u914d\u7f6e\u53ef\u80fd\u9700\u8981\u6570\u79d2\u5230\u6570\u5206\u949f\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9a8c\u8bc1\u5b89\u88c5<\/strong><\/p>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7\u5728Python\u73af\u5883\u4e2d\u5bfc\u5165matplotlib\u6765\u9a8c\u8bc1\u5b89\u88c5\u662f\u5426\u6210\u529f\u3002\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import matplotlib<\/p>\n<p>print(matplotlib.__version__)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u5982\u679c\u6ca1\u6709\u9519\u8bef\u4fe1\u606f\uff0c\u5e76\u4e14\u8f93\u51fa\u7248\u672c\u53f7\uff0c\u5219\u8868\u793a\u5b89\u88c5\u6210\u529f\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e8c\u3001\u4f7f\u7528ANACONDA\u5b89\u88c5MATPLOTLIB<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u88c5Anaconda<\/strong><\/p>\n<\/p>\n<p><p>\u5982\u679c\u8fd8\u6ca1\u6709\u5b89\u88c5Anaconda\uff0c\u53ef\u4ee5\u4eceAnaconda\u5b98\u7f51\u4e0b\u8f7d\u5b89\u88c5\u7a0b\u5e8f\uff0c\u5e76\u6839\u636e\u63d0\u793a\u5b8c\u6210\u5b89\u88c5\u3002Anaconda\u662f\u4e00\u4e2a\u96c6\u6210\u7684Python\u53d1\u884c\u7248\uff0c\u5305\u542b\u4e86\u8bb8\u591a\u79d1\u5b66\u8ba1\u7b97\u548c\u6570\u636e\u5206\u6790\u7684\u5e38\u7528\u5e93\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u6253\u5f00Anaconda Prompt<\/strong><\/p>\n<\/p>\n<p><p>\u5728\u5b89\u88c5\u4e86Anaconda\u4e4b\u540e\uff0c\u6253\u5f00Anaconda Prompt\uff08\u5728Windows\u7cfb\u7edf\u4e2d\uff09\u6216\u6253\u5f00\u7ec8\u7aef\uff08\u5728macOS\u6216Linux\u7cfb\u7edf\u4e2d\uff09\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b89\u88c5MATPLOTLIB<\/strong><\/p>\n<\/p>\n<p><p>\u5728Anaconda Prompt\u6216\u7ec8\u7aef\u4e2d\uff0c\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">conda install matplotlib<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8be5\u547d\u4ee4\u5c06\u4eceAnaconda\u7684\u5b98\u65b9\u5e93\u4e2d\u4e0b\u8f7d\u5e76\u5b89\u88c5matplotlib\u5e93\u53ca\u5176\u4f9d\u8d56\u9879\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9a8c\u8bc1\u5b89\u88c5<\/strong><\/p>\n<\/p>\n<p><p>\u4e0e\u4f7f\u7528pip\u5b89\u88c5\u540e\u7684\u9a8c\u8bc1\u6b65\u9aa4\u76f8\u540c\uff0c\u8fdb\u5165Python\u73af\u5883\uff0c\u5c1d\u8bd5\u5bfc\u5165matplotlib\u5e76\u8f93\u51fa\u5176\u7248\u672c\u53f7\u4ee5\u9a8c\u8bc1\u5b89\u88c5\u662f\u5426\u6210\u529f\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e09\u3001\u4ece\u6e90\u7801\u5b89\u88c5MATPLOTLIB<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u4e0b\u8f7d\u6e90\u7801<\/strong><\/p>\n<\/p>\n<p><p>\u524d\u5f80matplotlib\u7684\u5b98\u65b9\u7f51\u7ad9\u6216GitHub\u9875\u9762\uff0c\u4e0b\u8f7d\u6700\u65b0\u7248\u672c\u7684\u6e90\u7801\u6587\u4ef6\u3002\u901a\u5e38\u4ee5zip\u6216tar.gz\u683c\u5f0f\u63d0\u4f9b\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u89e3\u538b\u6e90\u7801<\/strong><\/p>\n<\/p>\n<p><p>\u4e0b\u8f7d\u5b8c\u6210\u540e\uff0c\u5c06\u6587\u4ef6\u89e3\u538b\u81f3\u4e00\u4e2a\u76ee\u5f55\u4e2d\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u5b89\u88c5\u4f9d\u8d56\u9879<\/strong><\/p>\n<\/p>\n<p><p>\u5728\u5b89\u88c5matplotlib\u4e4b\u524d\uff0c\u9700\u8981\u786e\u4fdd\u7cfb\u7edf\u4e0a\u5b89\u88c5\u4e86\u6240\u6709\u5fc5\u9700\u7684\u4f9d\u8d56\u9879\u3002\u8fd9\u4e9b\u4f9d\u8d56\u9879\u5305\u62ecPython\u3001NumPy\u3001libpng\u3001freetype\u7b49\u3002\u53ef\u4ee5\u901a\u8fc7\u64cd\u4f5c\u7cfb\u7edf\u7684\u5305\u7ba1\u7406\u5de5\u5177\u5b89\u88c5\u8fd9\u4e9b\u4f9d\u8d56\u9879\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u7f16\u8bd1\u548c\u5b89\u88c5<\/strong><\/p>\n<\/p>\n<p><p>\u6253\u5f00\u547d\u4ee4\u884c\u6216\u7ec8\u7aef\uff0c\u5bfc\u822a\u5230\u89e3\u538b\u540e\u7684\u6e90\u7801\u76ee\u5f55\u4e2d\uff0c\u6267\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python setup.py install<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8be5\u547d\u4ee4\u5c06\u7f16\u8bd1\u6e90\u7801\u5e76\u5b89\u88c5matplotlib\u5e93\u3002\u6839\u636e\u7cfb\u7edf\u914d\u7f6e\u4e0d\u540c\uff0c\u53ef\u80fd\u9700\u8981\u7ba1\u7406\u5458\u6743\u9650\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9a8c\u8bc1\u5b89\u88c5<\/strong><\/p>\n<\/p>\n<p><p>\u5982\u540c\u524d\u9762\u4e24\u79cd\u65b9\u6cd5\uff0c\u8fdb\u5165Python\u73af\u5883\uff0c\u5bfc\u5165matplotlib\u5e76\u8f93\u51fa\u7248\u672c\u53f7\u4ee5\u9a8c\u8bc1\u5b89\u88c5\u662f\u5426\u6210\u529f\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u56db\u3001\u89e3\u51b3\u5e38\u89c1\u95ee\u9898<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u7f51\u7edc\u95ee\u9898<\/strong><\/p>\n<\/p>\n<p><p>\u5728\u4f7f\u7528pip\u6216conda\u5b89\u88c5matplotlib\u65f6\uff0c\u53ef\u80fd\u4f1a\u9047\u5230\u7f51\u7edc\u95ee\u9898\u5bfc\u81f4\u5b89\u88c5\u5931\u8d25\u3002\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u4f7f\u7528\u56fd\u5185\u955c\u50cf\u6e90\u8fdb\u884c\u5b89\u88c5\u3002\u4f8b\u5982\uff0c\u4f7f\u7528pip\u5b89\u88c5\u65f6\u53ef\u4ee5\u901a\u8fc7<code>-i<\/code>\u9009\u9879\u6307\u5b9a\u955c\u50cf\u6e90\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install matplotlib -i https:\/\/pypi.tuna.tsinghua.edu.cn\/simple<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u6743\u9650\u95ee\u9898<\/strong><\/p>\n<\/p>\n<p><p>\u5982\u679c\u5728\u5b89\u88c5\u8fc7\u7a0b\u4e2d\u9047\u5230\u6743\u9650\u95ee\u9898\uff0c\u53ef\u4ee5\u5c1d\u8bd5\u4f7f\u7528\u7ba1\u7406\u5458\u6743\u9650\u8fd0\u884c\u547d\u4ee4\u3002\u5728Windows\u4e0a\uff0c\u53ef\u4ee5\u53f3\u952e\u5355\u51fb\u547d\u4ee4\u63d0\u793a\u7b26\u5e76\u9009\u62e9\u201c\u4ee5\u7ba1\u7406\u5458\u8eab\u4efd\u8fd0\u884c\u201d\uff1b\u5728Linux\u6216macOS\u4e0a\uff0c\u53ef\u4ee5\u5728\u547d\u4ee4\u524d\u52a0\u4e0a<code>sudo<\/code>\u4ee5\u63d0\u5347\u6743\u9650\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u4f9d\u8d56\u51b2\u7a81<\/strong><\/p>\n<\/p>\n<p><p>\u5982\u679c\u5728\u5b89\u88c5\u8fc7\u7a0b\u4e2d\u51fa\u73b0\u4f9d\u8d56\u51b2\u7a81\uff0c\u53ef\u80fd\u662f\u56e0\u4e3a\u7cfb\u7edf\u4e2d\u5df2\u7ecf\u5b89\u88c5\u4e86\u4e0ematplotlib\u4e0d\u517c\u5bb9\u7684\u5e93\u7248\u672c\u3002\u53ef\u4ee5\u5c1d\u8bd5\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u865a\u62df\u73af\u5883\uff0c\u786e\u4fdd\u73af\u5883\u4e2d\u7684\u5e93\u662f\u9694\u79bb\u548c\u517c\u5bb9\u7684\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u4e94\u3001\u5728\u865a\u62df\u73af\u5883\u4e2d\u5b89\u88c5MATPLOTLIB<\/p>\n<\/p>\n<ol>\n<li>\n<p><strong>\u521b\u5efa\u865a\u62df\u73af\u5883<\/strong><\/p>\n<\/p>\n<p><p>\u4f7f\u7528<code>venv<\/code>\u6a21\u5757\u521b\u5efa\u4e00\u4e2a\u65b0\u7684Python\u865a\u62df\u73af\u5883\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">python -m venv myenv<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u8fd9\u91cc\u7684<code>myenv<\/code>\u662f\u865a\u62df\u73af\u5883\u7684\u540d\u79f0\uff0c\u53ef\u4ee5\u6839\u636e\u9700\u8981\u8fdb\u884c\u4fee\u6539\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u6fc0\u6d3b\u865a\u62df\u73af\u5883<\/strong><\/p>\n<\/p>\n<p><p>\u6839\u636e\u64cd\u4f5c\u7cfb\u7edf\u4e0d\u540c\uff0c\u6fc0\u6d3b\u865a\u62df\u73af\u5883\u7684\u547d\u4ee4\u6709\u6240\u4e0d\u540c\uff1a<\/p>\n<\/p>\n<ul>\n<li>\n<p>Windows:<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">myenv\\Scripts\\activate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p>macOS\u548cLinux:<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">source myenv\/bin\/activate<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u5728\u865a\u62df\u73af\u5883\u4e2d\u5b89\u88c5MATPLOTLIB<\/strong><\/p>\n<\/p>\n<p><p>\u6fc0\u6d3b\u865a\u62df\u73af\u5883\u540e\uff0c\u4f7f\u7528pip\u547d\u4ee4\u5b89\u88c5matplotlib\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install matplotlib<\/p>\n<p><\/code><\/pre>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u9a8c\u8bc1\u5b89\u88c5<\/strong><\/p>\n<\/p>\n<p><p>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u8fdb\u5165Python\u73af\u5883\uff0c\u5bfc\u5165matplotlib\u5e76\u8f93\u51fa\u5176\u7248\u672c\u53f7\u4ee5\u9a8c\u8bc1\u5b89\u88c5\u662f\u5426\u6210\u529f\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u4f60\u53ef\u4ee5\u6839\u636e\u81ea\u5df1\u7684\u9700\u6c42\u9009\u62e9\u9002\u5408\u7684\u65b9\u5f0f\u5b89\u88c5matplotlib\u3002\u65e0\u8bba\u662f\u901a\u8fc7pip\u3001Anaconda\u8fd8\u662f\u4ece\u6e90\u7801\u5b89\u88c5\uff0c\u90fd\u5404\u6709\u4f18\u7f3a\u70b9\u3002\u5bf9\u4e8e\u5927\u591a\u6570\u7528\u6237\u6765\u8bf4\uff0cpip\u662f\u6700\u7b80\u5355\u4e14\u63a8\u8350\u7684\u5b89\u88c5\u65b9\u5f0f\uff0c\u800cAnaconda\u9002\u5408\u4e8e\u9700\u8981\u7ba1\u7406\u591a\u4e2a\u6570\u636e\u79d1\u5b66\u5e93\u7684\u7528\u6237\u3002\u5bf9\u4e8e\u9ad8\u7ea7\u7528\u6237\u6216\u6709\u7279\u6b8a\u9700\u6c42\u7684\u7528\u6237\uff0c\u4ece\u6e90\u7801\u5b89\u88c5\u63d0\u4f9b\u4e86\u6700\u5927\u7684\u7075\u6d3b\u6027\u3002\u65e0\u8bba\u9009\u62e9\u54ea\u79cd\u65b9\u5f0f\uff0c\u786e\u4fdd\u5b89\u88c5\u8fc7\u7a0b\u4e2d\u89e3\u51b3\u4efb\u4f55\u51fa\u73b0\u7684\u95ee\u9898\uff0c\u4ee5\u4fbf\u987a\u5229\u4f7f\u7528matplotlib\u8fdb\u884c\u6570\u636e\u53ef\u89c6\u5316\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u5728Python\u4e2d\u5b89\u88c5matplotlib\u5e93\uff1f<\/strong><br \/>\u8981\u5b89\u88c5matplotlib\u5e93\uff0c\u53ef\u4ee5\u4f7f\u7528Python\u7684\u5305\u7ba1\u7406\u5de5\u5177pip\u3002\u5728\u547d\u4ee4\u884c\u6216\u7ec8\u7aef\u4e2d\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a  <\/p>\n<pre><code>pip install matplotlib\n<\/code><\/pre>\n<p>\u786e\u4fdd\u5728\u5b89\u88c5\u524d\u5df2\u6b63\u786e\u5b89\u88c5Python\u548cpip\u3002\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7\u5728Python\u73af\u5883\u4e2d\u8f93\u5165<code>import matplotlib<\/code>\u6765\u9a8c\u8bc1\u5b89\u88c5\u662f\u5426\u6210\u529f\u3002<\/p>\n<p><strong>\u5982\u679c\u5728\u5b89\u88c5matplotlib\u65f6\u9047\u5230\u9519\u8bef\uff0c\u5e94\u8be5\u5982\u4f55\u89e3\u51b3\uff1f<\/strong><br \/>\u5e38\u89c1\u7684\u9519\u8bef\u53ef\u80fd\u662fpip\u672a\u66f4\u65b0\u6216\u7f51\u7edc\u95ee\u9898\u3002\u53ef\u4ee5\u901a\u8fc7\u8fd0\u884c<code>pip install --upgrade pip<\/code>\u6765\u66f4\u65b0pip\u3002\u5982\u679c\u4ecd\u7136\u9047\u5230\u95ee\u9898\uff0c\u5c1d\u8bd5\u4f7f\u7528VPN\u6216\u68c0\u67e5\u7f51\u7edc\u8fde\u63a5\u3002\u6709\u65f6\u5019\uff0c\u4f7f\u7528<code>pip install matplotlib --user<\/code>\u547d\u4ee4\u53ef\u4ee5\u89e3\u51b3\u6743\u9650\u95ee\u9898\u3002<\/p>\n<p><strong>\u662f\u5426\u53ef\u4ee5\u901a\u8fc7Anaconda\u5b89\u88c5matplotlib\uff1f<\/strong><br \/>\u662f\u7684\uff0cAnaconda\u63d0\u4f9b\u4e86\u4e00\u79cd\u7b80\u5355\u7684\u65b9\u6cd5\u6765\u5b89\u88c5matplotlib\u3002\u53ea\u9700\u6253\u5f00Anaconda Prompt\uff0c\u7136\u540e\u8f93\u5165\u4ee5\u4e0b\u547d\u4ee4\uff1a  <\/p>\n<pre><code>conda install matplotlib\n<\/code><\/pre>\n<p>\u8fd9\u79cd\u65b9\u6cd5\u4f1a\u81ea\u52a8\u5904\u7406\u4f9d\u8d56\u5173\u7cfb\uff0c\u9002\u5408\u4f7f\u7528Anaconda\u73af\u5883\u7684\u7528\u6237\u3002<\/p>\n<p><strong>\u5b89\u88c5\u5b8cmatplotlib\u540e\uff0c\u6211\u5982\u4f55\u5f00\u59cb\u4f7f\u7528\u5b83\u8fdb\u884c\u6570\u636e\u53ef\u89c6\u5316\uff1f<\/strong><br \/>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u53ef\u4ee5\u901a\u8fc7\u7f16\u5199\u7b80\u5355\u7684\u4ee3\u7801\u5f00\u59cb\u4f7f\u7528matplotlib\u8fdb\u884c\u6570\u636e\u53ef\u89c6\u5316\u3002\u4f8b\u5982\uff0c\u60a8\u53ef\u4ee5\u7ed8\u5236\u4e00\u4e2a\u7b80\u5355\u7684\u6298\u7ebf\u56fe\uff1a  <\/p>\n<pre><code class=\"language-python\">import matplotlib.pyplot as plt\n\nx = [1, 2, 3, 4]\ny = [10, 20, 25, 30]\n\nplt.plot(x, y)\nplt.title(&#39;\u7b80\u5355\u6298\u7ebf\u56fe&#39;)\nplt.xlabel(&#39;X\u8f74&#39;)\nplt.ylabel(&#39;Y\u8f74&#39;)\nplt.show()\n<\/code><\/pre>\n<p>\u8fd9\u6bb5\u4ee3\u7801\u4f1a\u751f\u6210\u4e00\u4e2a\u57fa\u672c\u7684\u6298\u7ebf\u56fe\uff0c\u5e2e\u52a9\u60a8\u5feb\u901f\u4e0a\u624b\u4f7f\u7528matplotlib\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5728Python\u4e2d\u5b89\u88c5matplotlib\u901a\u5e38\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u65b9\u6cd5\u5b9e\u73b0\uff1a\u4f7f\u7528pip\u547d\u4ee4\u3001\u901a\u8fc7Anaconda\u5b89\u88c5\u3001\u4ece [&hellip;]","protected":false},"author":3,"featured_media":946503,"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\/946499"}],"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=946499"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/946499\/revisions"}],"predecessor-version":[{"id":946504,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/946499\/revisions\/946504"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/946503"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=946499"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=946499"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=946499"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}